generator with subfunction calling yield
andy.leszczynski at gmail.com
andy.leszczynski at gmail.com
Wed Sep 27 18:39:06 EDT 2006
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():
print i
gives results:
$ python f.py
inside
1
before
after
Traceback (most recent call last):
File "f.py", line 18, in ?
for i in nn():
TypeError: iteration over non-sequence
while I would expect:
$ python f.py
inside
1
before
inside
1
after
Any insight?
andy
More information about the Python-list
mailing list