Operator precedence problem

Chris Angelico rosuav at gmail.com
Mon Jun 6 11:57:34 EDT 2016


On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens
<jon+usenet at unequivocal.co.uk> wrote:
>>> You should put brackets around expressions when it's at all unclear
>>> what the meaning is. You could think of them a bit like "active
>>> comments" I suppose.
>>
>> Your code should keep noise to the minimum.
>
> Sensible and beneficial comments aren't "noise".

In that case, please never insult the intelligence of your future
readers by including any of these parentheses:

x = 1 + (2 * 3)
value = 77 if (x % 2) else (70*7)

And if your readers have to figure out what 3**3**3 is interpreted as,
there should be an interactive interpreter around. Or here - try
something cute:

>>> 2**2**-1

ChrisA



More information about the Python-list mailing list