[Python-ideas] return value of yield expressions

Guido van Rossum guido at python.org
Tue Sep 13 19:34:35 CEST 2011


On Tue, Sep 13, 2011 at 10:21 AM, H. Krishnan <hetchkay at gmail.com> wrote:
>> > (a1, a2, a3 = 3, *args, **kwds) = (yield <expr>)
>>
>> What on earth is this syntax supposed to mean? Never mind that there's
>> a yield on the RHS; it is just a parenthesized expression so it could
>> could be any other function. What on earth do you expect to happen
>> with the syntax on the left, i.e. with the part
>
>
>>
>> (a1, a2, a3 = 3, *args, **kwds) = ........whatever........
>
> As I said "forgeting the backward compatibility issue".

It's not a backwards compatibility issue. Maybe I'm dense, but *I do
not understand what it means in your proposal.*

> Suppose we use
> Jacob's syntax (for argument's sake)

> *(a1, a2, a3 = 3, *args, **kwds) = (yield expr)

> and with g.send(*a, **k) being called, a1, a2, a3, args, kwds can be
> inferred using the same semantics that is used to decipher a1, a2, a3, args,
> kwds in a call to the following function with *a and **k as arguments:
> def func(a1, a2, a3 = 3, *args, **kwds):
>    ...

I still don't follow. Can you show a specific argument list to send,
e.g. g.send(1, 2, 3, foo='a', bar='b') and then tell me what the
values of a1, a2, a3, args and kwds will be? And, since

X = Y

should always be equivalent to

tmp = Y
X = tmp

can you also tell me what value is supposed to be produced by (yield
expr)? I.e. if I did this:

tmp = (yield expr)
*(a1, a2, a3 = 3, *args, **kwds) = tmp

what would the value of tmp be?

> That (yield expr) can be used in expressions does not (I feel) affect this
> (particularly if we go with Jacob's suggestion of this being a general
> unpacking option), just in the same way that "a, b, *args, c = <tuple>" does
> not affect using tuples in expressions. But after reading your comment in
> another thread about those who don't know how python works should keep
> quiet, I guess it is best if I end this here :-)

I understand "a, b, *c = <something>". I do not understand three
things in your example:

*(....) = <something>  # What is the meaning of the prefix *?

*(.... = .....) = <something>  # What does an = inside parentheses mean?

*(.... = ......, **kwds) = <something>  # What does **kwds mean in this context?

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list