what does := means simply?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 17 09:32:11 EDT 2018


On Thu, 17 May 2018 12:58:43 +0100, bartc 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.

Seriously? You think we have a responsibility to write examples which 
will work with arbitrary languages with arbitrarily different evaluation 
order?

Okay, let's be clear:

- if the language has different evaluation order, it might not work;

- if the language has different syntax, it might not work;

- if the language has not variables or names, it might not work;

- if the language uses something other than decimal for numeric
  literals, it might not work;

- if the language doesn't use + * and ** for addition, multiplication
  and exponentiation, it might not work;

- if the language has no print, it might not work;

- if the language doesn't use ( ) for function calls, it might
  not work;

- or if the print function does something else, say, erases your 
  hard disk, you probably don't want to run that example;

- or if the language has no I/O, or no functions, it might not 
  do what you expect either;

- and if the language doesn't actually have a working interpreter
  or compiler for any existing computer, you may have trouble
  getting the code to run.


Did I miss any other problems?


-- 
Steve




More information about the Python-list mailing list