[Python-Dev] Re: comprehension abbreviation (was: Adding any() and
all())
Jim Jewett
jimjjewett at gmail.com
Wed Mar 16 02:54:07 CET 2005
Gareth McCaughan wrote:
> Some bit of my brain is convinced that [x in stuff if condition]
> is the Right Syntax and keeps making me type it even though
> I know it doesn't work.
(and I agree with Gareth)
On Monday 2005-03-14 12:42, Eric Nieuwland wrote:
> The full syntax is:
> [ f(x) for x in seq if pred(x) ]
> being allowed to write 'x' instead of 'identity(x)' is already a
> shortcut, just as dropping the conditional part.
I think this is the heart of the disagreement.
Mentally, I'm not collecting some function of x (which happens
to be identity). I am filtering an existing set. Being able to
collect f(x) instead is just a useful but hackish shortcut.
Gareth again:
> and in fact no set theorist would be at all troubled by seeing
> { x in S : predicate(x) }
> which is the nearest equivalent in mathematical notation
> for the abbreviated comprehension expressions being discussed.
Again, I agree. I think that is what I am unconsciously writing,
by translating the ":" into "if"
-jJ
More information about the Python-Dev
mailing list