[ create a new paste ] login | about

Link: http://codepad.org/fOvZKSPP    [ raw code | output | fork ]

aaronla - Python, pasted on May 10:
1
2
3
4
5
6
7
8
def f():
  print "f->", (yield 1)
  print "f->", (yield 2)

g = f();
print "g->", g.next()
print "g->", g.send(3)
print "g->", g.send(4)


Output:
1
2
3
4
5
6
7
8
g-> f-> 1
g-> 3
f-> 2
g-> 4
Traceback (most recent call last):
  Line 8, in <module>
    print "g->", g.send(4)
StopIteration


Create a new paste based on this one


Comments: