A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-March/087752.html below:

[Python-Dev] PEP 380 (yield from a subgenerator) comments

[Python-Dev] PEP 380 (yield from a subgenerator) comments [Python-Dev] PEP 380 (yield from a subgenerator) commentsGreg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 27 06:53:23 CET 2009
Guido van Rossum wrote:

> That +0 could turn into a +1 if there was a way to flag this as an
> error (at runtime), at least if the return is actually executed:
> 
> def g():
>     yield 42
>     return 43
> 
> for x in g():
>     print x    # probably expected to print 42 and then 43
> 
> Perhaps the exception used in this case could be a different exception
> than StopIteration?

Would checking that the value is None be sufficient? Or do you
want to distinguish between 'return' and 'return None'? That
would feel rather strange to me.

I'm inclined to regard this as an unnecessary complication.
People are already trained to think of 'return' and 'yield'
as quite different things. I don't know why they would suddenly
start using 'return' when they mean 'yield'.

-- 
Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4