[Python-ideas] Inline assignments using "given" clauses

Chris Angelico rosuav at gmail.com
Sat May 12 17:42:19 EDT 2018

On Sun, May 13, 2018 at 7:33 AM, Ed Kellett <e+python-ideas at kellett.im> wrote:
> On 2018-05-12 19:27, Steven D'Aprano wrote:
>> What you probably want is the second version:
>> (a := c.d()).b(a)
>> which of course looks like utter crap. It might look better if we
>> use at least half-way sensible variable names and a more realistic
>> looking example, instead of obfuscated one-letter names.
>> (widget := widget_builder.new(*args)).method(widget)
> I believe that that's missing the point: to wit, in
>     x.method(y)
> is `x` or `y` evaluated first? I didn't know. I don't think the order is
> documented anywhere or guaranteed not to change. I don't know what other
> languages do in general, though I know in C it's explicitly unspecified.

It's documented. It's guaranteed not to change.



More information about the Python-ideas mailing list