[Python-Dev] comprehension abbreviation (was: Adding any() and all())

Nick Coghlan ncoghlan at iinet.net.au
Sat Mar 12 01:43:48 CET 2005


Jim Jewett wrote:
> Note that the last x shouldn't have to be x.
> 
>     [x in seq if f(x)] 
> 
> is by far my most common syntax error, and 
> 
>     [x for x in seq if f(x)]
> 
> is always what I want instead.

That 'x in seq' bit still shouts "containment" to me rather than iteration, though.

Perhaps repurposing 'from':

   (x from seq if f(x))

That rather breaks TOOWTDI though (since it is essentially new syntax for a for 
loop). And I have other hopes for the meaning of (x from ()). . .

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net


More information about the Python-Dev mailing list