----- Original Message ----- > From: "Neal Becker" <ndbeck...@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. -- https://mail.python.org/mailman/listinfo/python-list