On Sun, 6 Jul 2008 00:29:26 -0700, Mark Tolonen <[EMAIL PROTECTED]> wrote:
>
> "inhahe" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
...

>> note that this won't work;
>> def f():
>>  for x in xrange(10):
>>    for y in xrange(10):
>>      yield (x,y)
>>
>> yield just doesn't work right with multiple levels of loops. i had to 
>> discover that the hard way.
>
> Huh?  Works fine: [...]

Yes -- as is expected.  Yield would be much less useful if it only
work with strange restrictions on the structure of the function
containing it.

As far as I can tell, you can pick any function, stick zero or more
yield statements into it, and it will work as expected: hit a yield,
and you get another value for your sequence.

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.se>          R'lyeh wgah'nagl fhtagn!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to