Re: generator with subfunction calling yield

2006-09-27 Thread Matimus
The issue is that nn() does not return an iterable object. _nn() returns an iterable object but nothing is done with it. Either of the following should work though: def nn(): def _nn(): print 'inside' yield 1 print 'before' for i in _nn(): yield i print 'aft

Re: generator with subfunction calling yield

2006-09-27 Thread Rob Williscroft
wrote in news:[EMAIL PROTECTED] in comp.lang.python: > Any insight? >From the docs: The yield statement is only used when defining a generator function, and is only used in the body of the generator function. Using a yield statement in a function definition is sufficient to cause that defin

Re: generator with subfunction calling yield

2006-09-27 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hi, > > I might understand why this does not work, but I am not convinced it > should not - following: > > def nnn(): > print 'inside' > yield 1 > > def nn(): > def _nn(): > print 'inside' > yield 1 > > print 'before' > _nn() >

generator with subfunction calling yield

2006-09-27 Thread andy . leszczynski
Hi, I might understand why this does not work, but I am not convinced it should not - following: def nnn(): print 'inside' yield 1 def nn(): def _nn(): print 'inside' yield 1 print 'before' _nn() print 'after' for i in nnn(): print i for i in nn():