Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add section explaining 'yield' in list comp/generator exp #32
Comments
|
Ah, I went through the SO thread and the bug report but unfortunately couldn't come up with a simple and short explanation. So I think for the time being, it's better to link to the resources you shared. Meanwhile I'll try to come up with a simpler explanation with the help of examples. |
|
@chris-rands Thanks for your suggestion. I've added this snippet in #45, and will try my best to add a detailed explanation for the same. |
|
@satwikkansal Thank you for incorporating my suggestion and apologies for not responding before; I don't think I can provide a better explanation than that given in the links but it might be worth adding that this behaviour described may change because this really is a bug and not a feature. As the bug report states, for PyPy these constructs now raise a |
|
Update: see the more recent discussion on the bug report bugs.python.org/issue10544; this syntax will sometimes raise a |
These examples illustrate what for me is one of the most confusing behaviours in the whole of Python:
A relevant SO question and bug report