Re: yield_all needed in Python

From: Mike C. Fletcher (mcfletch_at_rogers.com)
Date: 03/01/05


Date: Tue, 01 Mar 2005 14:48:02 -0500
To: python-list@python.org

Skip Montanaro wrote:
...

>If this idea advances I'd rather see extra syntactic sugar introduced to
>complement the current yield statement instead of adding a new keyword.
>It's a bit clumsy to come up with something that will work syntactically
>since the next token following the yield keyword can be any identifier.
>You'd thus need another keyword there. Something like:
>
>
I'd agree on *not* introducing a new keyword. I run into this issue
every once in a while, but new keywords for minor syntactic sugar seems
a bit much.

> # Some code here
> yield from foogen1(arg3)
>
>
...

>It would be nicer if that was
>
> yield all from <something>
>
>
I don't really like the need to look past that (potentially long)
expression to see the effect of the operation. I don't mind the yield
from syntax, it nicely encapsulates the learning of "generators" so that
when you see yield up front you know something generatish is going on.

I'd be fine with:

    for yield on foogen1(arg3)

or

    for yield from foogen1(arg3)

which goes more toward the idea of being syntactic sugar for a for loop
that yields each value that is produced. Of course, what happens with:

    [ for yield from foogen1(arg3) ]

would then have to be defined... that might make it too complex an
change. Oh well.

Have fun all,
Mike

________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com
                              PyCon is coming...



Relevant Pages

  • Re: Yield should be renamed call_block
    ... languages for example in CLU. ... keyword will be removed from the language, and you will access blocks ... to the OP, Of course with your won individual modules/libraries loaded/required, you can alias yield to be whatever isn't already taken by something else. ...
    (comp.lang.ruby)
  • Re: Prothon gets Major Facelift in Vers 0.1.0 [Prothon]
    ... > def evens: ... my tutorial writing skills :-) ... yield i ... The way it works is that the "gen" keyword is just a special flag to tell ...
    (comp.lang.python)
  • Re: Style question on recursive generators
    ... >> yield' look ugly to someone else? ... > Perhaps some syntax hack such as a new statement keyword 'yieldall' ... for child in childs: ... blog: http://rascunhosrotos.blogspot.com ...
    (comp.lang.python)
  • Re: The :: operator, and "global"
    ... > is placed between two identifiers ... Technically, global is not a keyword (neither are get, set, value, partial, ... alias, add, remove, where, yield). ...
    (microsoft.public.dotnet.languages.csharp)