[Python-Dev] accumulator display syntax
Alex Martelli
aleaxit at yahoo.com
Fri Oct 17 16:01:50 EDT 2003
More information about the Python-Dev mailing list
Fri Oct 17 16:01:50 EDT 2003
- Previous message: [Python-Dev] Re: accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Friday 17 October 2003 08:57 pm, Skip Montanaro wrote:
...
> Forgive my extreme density on this matter, but I don't understand what
>
> (yield x for x in S)
>
> is supposed to do. Is it supposed to return a generator function which I
> can assign to a variable (or pass to the builtin function sum() as in your
> example) and call later, or is it supposed to turn the current function
> into a generator function (so that each executed yield statement returns a
> value to the caller of the current function)?
Neither: it returns an iterator, _equivalent_ to the one that would be
returned by _calling_ a generator such as
def xxx():
for x in S:
yield x
like xxx() [the result of the CALL to xxx, as opposed to xxx itself], (yield:
x for x in S) is not callable; rather, it's loopable-on.
> you don't like lambda, I can't quite see why syntax this is all that
> appealing.
I don't really like the current state of lambda (and it will likely never get
any better), I particularly don't like the use of the letter lambda for this
idea (Church's work notwithstanding, even Paul Graham in his new lispoid
language has chosen a more sensible keyword, 'func' I believe), but I like
comprehensions AND iterators, and the use of the word yield in generators.
I'm not quite sure what parallels you see between the two cases.
Alex
- Previous message: [Python-Dev] Re: accumulator display syntax
- Next message: [Python-Dev] accumulator display syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list