Is there a more elegant way to spell this?

Neal Becker ndbecker2 at gmail.com
Tue Jan 27 09:37:49 EST 2015


Jussi Piitulainen wrote:
> Neal Becker writes:
>>> Is there a more elegant way to spell this?
>>>> for x in [_ for _ in seq if some_predicate]:
>> If you mean some_predicate(_), then possibly this.
>> for x in filter(some_predicate, seq):
> handle(x)
>
I like this best, except probably even better:
for x in ifilter (some_predicate, seq):


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /