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/2003-October/038881.html below:

[Python-Dev] accumulator display syntax

[Python-Dev] accumulator display syntaxArmin Rigo arigo at tunes.org
Fri Oct 17 14:28:11 EDT 2003
Hello,

On Fri, Oct 17, 2003 at 11:55:53AM -0600, Shane Holloway (IEEE) wrote:
>     mygenerator = x for x in S
> 
>     for y in x for x in S:
>         print y
> 
>     return x for x in S

Interesting but potentially confusing: we could expect the last one to mean
that we executing 'return' repeatedly, i.e. returning a value more than once,
which is not what occurs.  Similarily,

   yield x for x in g()

in a generator would be quite close to the syntax discussed some time ago to
yield all the values yielded by a sub-generator g, but in your proposal it
wouldn't have that meaning: it would only yield a single object, which happens
to be an iterator with the same elements as g().

Even with parenthesis, and assuming a syntax to yield from a sub-generator for
performance reason, the two syntaxes would be dangerously close:

   yield x for x in g()       # means for x in g(): yield x
   yield (x for x in g())     # means yield g()


Armin


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