what does := means simply?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 17 13:19:40 EDT 2018


On Thu, 17 May 2018 15:50:17 +0100, bartc wrote:

> On 17/05/2018 15:03, Chris Angelico wrote:
>> On Thu, May 17, 2018 at 9:58 PM, 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.
>>>
>>>
>> Python DOES guarantee it, and nobody cares about your personal toy
>> language other than you. :)
> 
> As I said, it's poor form.

"... to rely on a language's guaranteed features, because, well, for no 
reason really."


> Of course, full-on Python code is pretty much impossible to port
> anywhere else anyway.

*rolls eyes*

You know what "Turing Complete" means, don't you? Either:

- Python is the only Turing Complete programming language in the universe;

- Python is the only programming language in the universe which is
  strictly more powerful than a Turing Machine; or

- you're talking nonsense on stilts.


I know where I'd put my money.


Of course it may sometimes be tricky to mechanically port certain Python 
programs to languages which are less powerful (in the Blub sense). But 
this is nothing new: mechanically porting from one language to another is 
always fraught with problems, unless the languages are designed for that 
(e.g. Coffeescript and Javascript).

Any pair of languages will have code that is hard to port from one to the 
other without jumping through hoops. Try porting C code with lots of 
dynamic memory allocations and pointer accesses to COBOL, or Scheme code 
using continuations to Python, or Hyperscript text chunking code to 
Fortran.

But hard does not mean "pretty much impossible".




-- 
Steve




More information about the Python-list mailing list