yield_all needed in Python
Isaac To
iketo2 at netscape.net
Wed Mar 2 00:54:44 EST 2005
>>>>> "Douglas" == Douglas Alan <nessus at mit.edu> writes:
Douglas> If you actually try doing this, you will see why I want
Douglas> "yield_all".
Oh... I see your point.
I was about to suggest that the code in my posts before should be made
to work somehow. I mean, if in
def fun1(x):
if not x:
raise MyErr()
...
def fun2():
...
fun1(val)
fun2()
we can expect that main gets the exception thrown by fun1, why in
def fun1(x):
if not x:
yield MyObj()
...
def fun2():
fun1(val)
for a in fun2():
...
we cannot expect MyObj() to be yielded to main? But soon I found that
it is not realistic: there is no way to know that fun2 has generator
semantics. Perhaps that is a short-sightness in not introducing a new
keyword instead of def when defining generators.
Regards,
Isaac.
More information about the Python-list
mailing list