bodacydo bodacydo - 1 year ago 69
Python Question

How to get one value from a generator in Python?

Very basic question - how to get one value from a generator in Python?

So far I found I can get one by writing

gen.next()
. I just want to make sure this is the right way?

Answer Source

Yes, or next(gen) in 2.6+.