Co-routines

Michele Simionato mis6 at pitt.edu
Thu Jul 17 19:25:45 CEST 2003


<thewrights at ozemail.com.au> wrote in message news:<g7xRa.305$fF.9914 at nnrp1.ozemail.com.au>...
> (I recall the malevolent and  wicked ternary operator example that was
> posted here which fiddled with function source code in the metaclass... I'm
> still picking up pieces of my brain from the floor)
> 

Oops! ;-)

To make ammend, I send you this solution:

def f1():
    for i in range(1,4):
        print "1-%s" % i; yield i

def f2():
    for i in f1():
        print "2-%s" % i

f2()

This print

1-1
2-1
1-2
2-2
1-3
2-3

However I am not sure I understand
correctly what you have in mind, so
this solution may well be not relevant
at all!


   Michele




More information about the Python-list mailing list