breaking iteration of generator method

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


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


# .gen() is generator method.

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

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,


More information about the Python-list mailing list