Why is a generator expression called a expression?
Veek M
veek at dont-use-this.com
Mon Apr 20 04:49:39 EDT 2020
The docs state that a expression is some combination of value, operator,
variable and function. Also you cannot add or combine a generator
expression with a value as you would do with 2 + 3 + 4. For example,
someone on IRC suggested this
all(a == 'a' for a in 'apple') but
1. all is a function/method
2. so (whatever) in this case is a call but obviously it works so it must
be a generator object as well.. so.. how does 'all' the function object
work with the generator object that's being produced?
I can't for example do min 1,2,3 but i can do min (1,2,3) and the () are
not integral to a tuple - therefore one could argue that the () are part
of the call - not so with a generator Expression where the () are
integral to its existence as an object.
Could someone clarify further.
More information about the Python-list
mailing list