> Would you feel better if `yield` was always required?
Yes but then it's the same as defining a generator-function.
> For almost all the examples I've provided a corresponding equivalent in the
> current syntax, so are you saying that you're still confused now or that you
> can't figure it out until you look at the 'answer'?
I think it's ambiguous, like in this example:
clean = [
for line in lines:
stripped = line.strip()
if stripped:
stripped
]
what says that it's the last stripped that should be yielded?
> If that function is the whole statement and there is no other expression
> statement in the comprehension, it will be yielded. I can't tell if there's
> more to your question.
Imagine this one:
foo = [
for x in range(5):
f(x)
if x % 2:
x
]
what will be the result? [f(x) for x in range(5)]? [x for x in
range(5) if x%2]? [x if x%2 else f(x) for x in range(5)]?
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/3YLKX24UR2CCSKY2UWQHLAMVKSR3BX5P/
Code of Conduct: http://python.org/psf/codeofconduct/