%autosave 10 def f(x): return x+1, x+2 f(10) == (11, 12) def f(x): yield x+1 yield x+2 list(f(10)) == [11, 12] class Callable(object): def __call__(self, x): return x+1, x+2 Callable()(10) == (11, 12) def generator(x): y = None y = yield x+1, y y = yield x+1, y g = generator(10) print g.next() print g.send("abc")