Bug or intended behavior?

Marko Rauhamaa marko at pacujo.net
Mon Jun 5 16:05:41 EDT 2017


Michael Torrie <torriem at gmail.com>:

> On 06/05/2017 01:26 PM, Marko Rauhamaa wrote:
>> Interestingly, however, Python hasn't extended that principle to the
>> expression syntax. You could have:
>> 
>>    >>> 1 + 2*3
>>    7
>>    >>> 1+2 * 3
>>    9
>
> And thankfully they didn't. Because it wouldn't make sense to do so.
>
> Having whitespace indenting mimics how one thinks of blocks of code
> and how one might wright it in pseudocode. For expressions, however,
> no one thinks or writes pseudo-equations without considering the order
> of operations.

No-one? That's what tripped up the original poster.

> Completely different things. Maybe if the use of parenthesis was
> relatively recent, you might make an argument, but unlike braces, the
> use of parenthesis to override order of operations goes back hundreds
> of years, far longer than programming languages have been defining
> blocks.

There are numerous traditions:

   <URL: https://en.wikipedia.org/wiki/Order_of_operations>

Just think of the several common ways of performing calculations with
electronic calculators.


Marko



More information about the Python-list mailing list