I've read PEP-255 about Generators, but nothing is mentioned about changing the inner space of the generator during runtime - this could mean that "it works by mistake" but from what I understand about generators - this behavior is a by-product of the algorithm.
I'm attaching an example of a generator and an iterator that are supposed to do produce the same output. The Iterator doesn't work and produces a RuntimeError while the Generator finishes the task successfully.
What do you think? is it safe to use the generator function? if not - do you have another safe approach to add items to a generator during runtime?
Thanks,
Ido.
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
gen_temp.py
Description: 2758083287-gen_temp.py