trigger exception in generator

D

Dominic

I would like to trigger an
exception in a generator
upon return from "yield"
e.g.

def mySimulationTask():
while 1:
try:
# drive forward one simulation step
yield
# do some stuff
except HitWall:
# handle this disaster ;-)

How can I possibly do this?
Maybe by hacking some internal
generator variables? ;-)

Thanks,
Dominic

h i l l b r _at_ rhrk.uni-kl.de
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,635
Latest member
SkyePurves

Latest Threads

Top