A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/319563.html below:

Yielding a chain of values

Yielding a chain of valuesviridia at gmail.com viridia at gmail.com
Thu Sep 1 03:11:46 EDT 2005
This is why my original proposal used the '*' operator rather than a
keyword. The reasoning behind this is as follows: When calling a
function, a parameter of the form "*expression" expands to a list of
arguments. From the Python reference manual:

"If the syntax '*expression' appears in the function call, 'expression'
must evaluate to a sequence. Elements from this sequence are treated as
if they were additional positional arguments."

By (somewhat stretched) analogy, "yield *expression" would "expand" the
sequence into a series of multiple yields.

Of course, now that yield is an expression (as stated above), you would
indeed have to account for the fact that the yield statement used in
this way would yield a sequence of values:

   for x in yield *[ 1, 2, 3 ]:
      print x

So the '*' would not only signal that multiple values were being
yielded, but that multiple values are also being returned.

-- Talin


More information about the Python-list 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