Co-routines
Peter Hansen
peter at engcorp.com
Thu Jul 17 09:23:22 EDT 2003
thewrights at ozemail.com.au wrote:
>
> I have an application in which I want the users to be able to create python
> functions:
>
> def f1():
> print "1-1"
> print "1-2"
> print "1-3"
>
> def f2():
> print "2-1"
> print "2-2"
> print "3-3"
>
> and when my application runs, I want to execute these functions in
> "lock-step", so that the output looks like:
>
> 1-1
> 2-2
> 1-2
> 2-2
> 1-3
> 2-3
I think the problem is underspecified. What do you mean by the quoted
phrase "lock-step"? Your example includes only simple print statements,
which generate output to sys.stdout. What are you really trying to
accomplish? Do you want individual bytecodes to be executed one at a
time from a series of functions? Do you want any output to be interlaced
on a line-by-line basis? Any call to any I/O routine? Need more detail.
-Peter
More information about the Python-list
mailing list