Strange range

Fabien fabien.maussion at gmail.com
Fri Apr 1 10:16:30 EDT 2016


On 04/01/2016 03:26 PM, Steven D'Aprano wrote:
> Incorrect. range is a lazy sequence.

But how does range "know" that it has to start from scratch again? As in 
this example:

it = range(10)
for i in it:
     if i >= 3:
         break
for i in it:
     # why does it start from zero again?
     print(i)



More information about the Python-list mailing list