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

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Mar 13 07:57:58 CET 2005

Nick Coghlan wrote:
> 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 ()). . .

How about:

   (for x in seq if f(x))

It still has the word 'for' in it and avoids mentioning
x more times than necessary.

Although I can't help feeling that it should be some
other word instead, such as

   (all x in seq if f(x))


   (every x in seq if f(x))


More information about the Python-Dev mailing list