Operator precedence problem

ICT Ezy ictezy at gmail.com
Sun Jun 5 23:23:24 EDT 2016


On Monday, June 6, 2016 at 5:18:21 AM UTC+5:30, Michael Torrie wrote:
> On 06/05/2016 10:05 AM, Uri Even-Chen wrote:
> > My suggestion: Never write expressions, such as  2 ** 3 ** 2 or even 2 * 4
> > + 5, without parentheses. Always add parentheses - 2 ** (3 ** 2) (or (2 **
> > 3) **2) or (2 * 4) + 5 (or 2 * (4 + 5)).
> 
> I can understand using parenthesis when operator precedence isn't
> working the way you want or expect, but I certainly would not recommend
> using it for basic arithmetic with multiplication, division, addition
> and subtraction. The rules of precedence for multiplication and division
> are well known and well-understood. If a language failed to implement
> them that would be a bug.  I think for the simple things extraneous
> parenthesis makes expressions more difficult for a human to parse
> because he will tend to second guess himself owing to extra parens.

Thank you very much for your explanation


More information about the Python-list mailing list