PEP 255: Simple Generators

Greg Ewing see at my.signature
Tue Jun 19 08:21:14 CEST 2001


Something is bothering me about this. In fact,
it's bothering me a LOT. In the following, will
f() work as a generator-function:

  def f():
    for i in range(5):
      g(i)

  def g(i):
    for j in range(10):
      yield i,j

If I understand PEP255 correctly, this will *not*
work. But it seems entirely reasonable to me that
it *should* work. It *has* to work, otherwise how
am I to write generators that are too complicated
to fit into a single function?

Someone please tell me I'm wrong about this!
 
-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list