breaking iteration of generator method

Brian balex at sympatico.ca
Tue Nov 4 17:32:19 CET 2003


Hello;

What happens when a program breaks (think keyword 'break') its iteration
of a generator? Is the old state in the generator preserved?

Ex:

# .gen() is generator method.

for i in myObject.gen():
	if i == specialValue:
		break

Do subsequent calls to .gen() start off with new locals? Or, would
the iteration begin after the yielded 'i' that caused the for-statement
to exit?


Many thanks,

Brian.




More information about the Python-list mailing list