1 > 0 == True -> False

Roy Smith roy at panix.com
Thu Jan 30 13:53:42 EST 2014


On Thursday, January 30, 2014 10:09:03 AM UTC-5, Steven D'Aprano wrote:
> On Thu, 30 Jan 2014 09:08:58 -0500, Roy Smith wrote:
> 
> > 1) Assume that you don't have the full operator precedence table
> > memorized and just parenthesize everything.
> 
> Oh really? Do you actually write stuff like this?
> 
> b = ((2*a) + 1)

Well, OK, I exaggerated a bit.  Multiplication binds stronger than addition in any language I've ever used, so I assume I know that one.  But not much beyond that.

> if (b >= (-1)):

No, I wouldn't use either set of parens their either.  But, if I have any doubt at all, I rather than look it up, I just put parens.  And my threshold for doubt is pretty low.



More information about the Python-list mailing list