[Python-Dev] Generator objects and list comprehensions?
Ivan Levkivskyi
levkivskyi at gmail.com
Thu Jan 26 07:09:05 EST 2017
On 26 January 2017 at 00:53, Nathaniel Smith <njs at pobox.com> wrote:
>
> I'm not sure this is actually a good idea, given the potential for
> ambiguity and backwards compatibility considerations -- I'm kind of leaning
> towards the deprecate/error option on balance :-). But it's an option that
> would probably be less confusing than the status quo, and would make it
> easier to write the kind of straddling code the original poster was trying
> to write.
>
>
Concerning list/set/dict comprehensions, I am much more in favor of making
comprehensions simply equivalent to for-loops (more or less like you
proposed using yield from). The only reason to introduce auxiliary function
scope was to prevent the loop variables from leaking outside comprehensions.
Formally, this is indeed backward incompatible, but I doubt many people
depend on the current counter-intuitive behavior.
Concerning generator expressions, probably it is indeed better to simply
prohibit yield inside them.
--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170126/06dc8028/attachment.html>
More information about the Python-Dev
mailing list