allow line break at operators
Roy Smith
roy at panix.com
Mon Aug 15 09:41:33 EDT 2011
In article <mailman.2233.1313179799.1164.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
> Python uses the + and - symbols to mean addition
> and subtraction for good reason. Let's not alienate the mathematical
> mind by violating this rule.
Computer programming languages follow math conventions only in the most
vague ways. For example, standard math usage dictates that addition is
commutative. While this is true for adding integers, it's certainly not
true for adding strings (in any language which supports string addition).
Where to draw the line between math and programming languages is not an
easy question.
> It would be far safer to go the other way
> and demand parentheses on everything.
Demand, no, but sometimes it's a good idea. I've been writing computer
programs for close to 40 years, and I still have no clue what most of
the order of operations is. It's just not worth investing the brain
cells to remember such trivia (especially since the details change from
language to language). Beyond remembering the (apparently) universal
rule that {*, /} bind tighter than {+, -}, I pretty much just punt on
everything else and put in extra parens everywhere.
It's not the most efficient way to write code, and probably doesn't even
result in the prettiest code. But it sure does eliminate those
face-palm moments at the end of a long debugging session when you
realize that somebody got it wrong.
More information about the Python-list
mailing list