> So how does one access a generator one element at a time? I thought > next would do that so I tried: > > print(next(uneven_squares(10,1000))) > print(next(uneven_squares(10,1000))) > print(next(uneven_squares(10,1000)))
Each call to uneven_squares(10, 1000) creates a fresh iterator. You may want to bind it so that you can reuse the same value across multiple uses of next(). ####### us = uneven_squares(10, 1000) print(next(us)) print(next(us)) print(next(us)) ####### _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor