what does := means simply?

Paul Moore p.f.moore at gmail.com
Thu May 17 08:07:12 EDT 2018


On 17 May 2018 at 12:58, bartc <bc at freeuk.com> wrote:
> On 17/05/2018 04:54, Steven D'Aprano wrote:
>>
>> On Thu, 17 May 2018 05:33:38 +0400, Abdur-Rahmaan Janhangeer wrote:
>>
>>> what does := proposes to do?
>
>> A simple example (not necessarily a GOOD example, but a SIMPLE one):
>>
>> print(x := 100, x+1, x*2, x**3)
>
>
> It's also not a good example because it assumes left-to-right evaluation
> order of the arguments. Even if Python guarantees that, it might be a
> problem if the code is ever ported anywhere else.

It's a good example, because it makes it clear that the benefits of :=
are at least in some cases, somewhat dependent on the fact that Python
evaluates arguments left to right :-)

Paul



More information about the Python-list mailing list