Screwing Up looping in Generator
Chris Angelico
rosuav at gmail.com
Tue Jan 3 17:34:58 EST 2017
On Wed, Jan 4, 2017 at 10:05 AM, Deborah Swanson
<python at deborahswanson.net> wrote:
> Ok, I learned how to use generators in Python 2.7.8, which may be
> different from Python 3 for generators. But I learned from MIT's online
> introduction to python course, and they certainly seem to know python
> well. So what is the correct way to call the generator's next yield in
> Python 3? We only learned to use the next function. If you don't use the
> next function, what do you use?
The built-in next function, not the next method.
# don't do this
gen.next()
# do this
next(gen)
ChrisA
More information about the Python-list
mailing list