from __future__ import generators def foo(): print 'bonjour' yield 1 print 'monde' yield 2