Martin v. Löwis wrote:
That's not the full syntax. The full syntax is
[ test for exprlist in testlist list-iter-opt ]
where
test can be an arbitrary expression: and, or, lambda, +, -, ...
exprlist can be a list of expression, except for boolean and
relational expressions (but I think this is
Eric Nieuwland wrote:
Martin v. Löwis wrote:
That's not the full syntax. The full syntax is
[ test for exprlist in testlist list-iter-opt ]
where
test can be an arbitrary expression: and, or, lambda, +, -, ...
exprlist can be a list of expression, except for boolean and
relational expressions
Eric Nieuwland wrote:
[ test for exprlist in testlist list-iter-opt ]
Aren't these names a bit mixed up w.r.t. what's in that position?
It comes more-or-less straight out of Grammar/Grammar, so: no,
I don't think so.
As far as I know
test is not a test but a function as it produces any value
Gareth McCaughan wrote:
I'd like it, and my reason isn't just to save typing.
There are two reasons.
1 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.
2 Seeing [x for x in stuff if
On Monday 2005-03-14 12:42, Eric Nieuwland wrote:
Gareth McCaughan wrote:
I'd like it, and my reason isn't just to save typing.
There are two reasons.
1 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
Title: RE: [Python-Dev] comprehension abbreviation (was: Adding any() and all())
[Gareth McCaughan]
#- 1 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.
My brain says: 'x in stuff
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,
That's a really strange way of looking at it. Unless
you would also say that
x = y
is a shorthand for
x = identity(y)
Not that it's false,
[Nick Coghlan]
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
[GvR]
- Before anybody asks, I really do think the reason this is
requested
at all is really just to save typing; there isn't the avoid double
evaluation argument that helped acceptance for assignment operators
(+= etc.), and I find redability is actually improved with 'for'.
{Neil
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 ()).
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
11 matches
Mail list logo