john-science / python_for_scientists

Python Open Courseware for Scientists and Engineers
GNU General Public License v3.0
68 stars 40 forks source link

Where is yield? #33

Closed john-science closed 8 years ago

john-science commented 9 years ago

I should add the keyword "yield" somewhere. Is there somewhere it won't clutter eveything up? Probably not. Still, it's super useful.

john-science commented 9 years ago

It would be nice to add a section on iterators somewhere... but where? Taking the Next Step? Std Libs 1?

john-science commented 9 years ago

I just need to define an iterator, show examples, define a generator, show xrange and xreadlines examples, and then show how to use yield to create your own generator.

There are lost of good references for this to point the student at:

And don't forget to mention the Python 2 versus Python 3 difference with xrange and xreadlines.