Generator syntax (Re: FW: FW: [Python-Dev] Simple generator implementation)

Greg Ewing greg@cosc.canterbury.ac.nz
Wed, 21 Mar 2001 16:49:33 +1200 (NZST)


>     def generate_kids(self):  # pre-order traversal
>         suspend self.value
>         for kid in self.children:
>             for itskids in kid.generate_kids():
>                 suspend itskids

Can I make a suggestion: If we're going to get this generator
stuff, I think it would read better if the suspending statement
were

   yield x

rather than

   suspend x

because x is not the thing that we are suspending!

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+