1 > 0 == True -> False

Roy Smith roy at panix.com
Thu Jan 30 09:49:17 EST 2014


In article <mailman.6143.1391091519.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> On Fri, Jan 31, 2014 at 1:08 AM, Roy Smith <roy at panix.com> wrote:
> > Better than that, do what I do.
> >
> > 1) Assume that you don't have the full operator precedence table
> > memorized and just parenthesize everything.
> 
> Or:
> 
> 1a) Assume that you don't have the full operator precedence table
> memorized and just look it up, for whichever language you're working
> with today. :)

It's faster to just stick in some extra parens.  Not to mention that it 
makes the code more clear for everybody reading it later.

Operator precedence is a tricky thing.  In part, because it's somewhat 
arbitrary, and in part because it changes from language to language.  
Using "extra" parens to make my meaning clear (to both the compiler and 
other humans who read the code in the future) is a simple technique 
which works in all languages.



More information about the Python-list mailing list