Why is a generator expression called a expression?

Veek M veek at dont-use-this.com
Mon Apr 20 06:23:26 EDT 2020


but one can do the following
(x for x in 'apple').next() * 2

def foo():
   (yield 2)
foo().next() * 3

(lambda x: 2)()*4

generator expr, yield expr, lambda expression 
all require some modification (insertion of a .next or explicit () so 
it's quite confusing.. 

expression seems to mean anything that gives a value with a little 
massaging..
with statements you can't combine them at all

assert 1 < 2
cannot be mixed at all with anything else unless you use a ; and even 
that won't work within ( )

is this reasonable?



More information about the Python-list mailing list