Generator Frustration

TommyVee xxxxxxxx at xxxxxx.xxx
Sat Jun 4 14:27:32 EDT 2011


I'm using the SimPy package to run simulations. Anyone who's used this 
package knows that the way it simulates process concurrency is through the 
clever use of yield statements. Some of the code in my programs is very 
complex and contains several repeating sequences of yield statements.  I 
want to combine these sequences into common functions.  The problem of 
course, is that once a yield gets put into a function, the function is now a 
generator and its behavior changes.  Is there any elegant way to do this?  I 
suppose I can do things like ping-pong yield statements, but that solutions 
seems even uglier than having a very flat, single main routine with 
repeating sequences.

Thanks in advance. 




More information about the Python-list mailing list