[ create a new paste ] login | about

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

aaronla - Python, pasted on May 10:
1
2
3
4
5
6
7
8
9
10
11
def printx(*args):
  print args

def f():
  printx("f->", (yield 1))
  printx("f->", (yield 2))

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


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


Create a new paste based on this one


Comments: