(why) inconsistent yield/return syntax?

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Mon Feb 10 22:59:35 EST 2003


In article <SoV1a.18262$qY4.18255 at news2.central.cox.net>, Steve Holden wrote:
[snip]
>Hope this helps. It doesn't make sense to have yield without an argument
>because the iterator protocol requires an object be returned.

This in itself isn't really an argument, is it?

It seems that people have been coming up with several creative uses
for generators, such as David Mertz's weightless threads, where the
main point of the yield is to freeze the execution of the generator,
not to return an object. This may break the intent behind the iterator
protocol, but it is the only way of achieving this sort of
functionality...

>You might argue that None shoud be a default, but I think that would
>be asking for trouble.

So, basically the question was "why is it thus?" and your answer is
that you think it should be...? Fair enough :)

-- 
Magnus Lie Hetland               "Nothing shocks me. I'm a scientist." 
http://hetland.org                                   -- Indiana Jones




More information about the Python-list mailing list