code review

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jul 2 20:57:40 EDT 2012


On Tue, 03 Jul 2012 02:55:48 +1000, Chris Angelico wrote:

> On Tue, Jul 3, 2012 at 1:16 AM, Rick Johnson
> <rantingrickjohnson at gmail.com> wrote:
>> py> 1 + 3 * 4
>> should ALWAYS equal 16!
>>
>> With parenthesis only used for grouping: py> a + (b*c) + d
>>
>> Which seems like the most consistent approach to me.
> 
> Oh yes, absolutely consistent. Consistency. It's a CR 1/2 monster found
> on page 153 of the 3.5th Edition Monster Manual.

GvR is fond of quoting Ralph Waldo Emerson:

"A foolish consistency is the hobgoblin of little minds."

Perhaps the world would be better off if mathematicians threw out the 
existing precedence rules and replaced them with a strict left-to-right 
precedence. (Personally, I doubt it.)

But until they do, consistency with mathematics is far more important 
than the foolish consistency of left-to-right precedence.


-- 
Steven



More information about the Python-list mailing list