semicolon at end of python's statements

Antoon Pardon antoon.pardon at rece.vub.ac.be
Fri Aug 30 03:15:26 EDT 2013


Op 30-08-13 06:55, Ben Finney schreef:
> Ben Finney <ben+python at benfinney.id.au> writes:
> 
>> Fábio Santos <fabiosantosart at gmail.com> writes:
>>
>>> It is a shame that this is not possible in python. for..if exists in
>>> comprehensions and not in regular loops but that would be nice
>>> sometimes.
>>     for foo in (spam for spam in sequence if predicate(spam)): …
> 
> Better:
> 
>     for foo in filter(predicate, sequence):
>         process(foo)

Well better in what way? You now have to translate a predicate
expression into a predicate function. Which AFAIU was one of
the reasons to move away from map/filter to list comprehension.

As I understand it, python made a move away from map and filter
towards list comprehension. Chris seems to want some of the
possibilities that came with that incorporated into the for
statement. And your suggestion is to go back to the old kind
of filter way.

-- 
Antoon Pardon



More information about the Python-list mailing list