I have a generator and I would like to know if I can use it without having to worry about StopIteration , and I would like to use it without the for item in generator . I would like to use it with a while statement for example ( or other constructs ). How could I do that ?
I have a generator and I would like to know if I can use
Share
Use this to wrap your generator:
Use it like this:
Update: Please use the answer below because it is much better than this one.