Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84644 > unrolled thread
| Started by | Jean-Michel Pichavant <jeanmichel@sequans.com> |
|---|---|
| First post | 2015-01-27 14:35 +0100 |
| Last post | 2015-01-27 14:35 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Re: Is there a more elegant way to spell this? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2015-01-27 14:35 +0100
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
|---|---|
| Date | 2015-01-27 14:35 +0100 |
| Subject | Re: Is there a more elegant way to spell this? |
| Message-ID | <mailman.18172.1422367680.18130.python-list@python.org> |
----- Original Message ----- > From: "Neal Becker" <ndbecker2@gmail.com> > To: python-list@python.org > Sent: Tuesday, 27 January, 2015 2:15:12 PM > Subject: Is there a more elegant way to spell this? > > Is there a more elegant way to spell this? > > for x in [_ for _ in seq if some_predicate]: You could use a generator expression for x in (_ for _ in seq if some_predicate): This is very similar but it prevents python from creating a new list. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Back to top | Article view | comp.lang.python
csiph-web