allow line break at operators
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Aug 15 10:28:23 EDT 2011
Roy Smith wrote:
> 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).
Not quite true for maths either, at least in principle. I'm not aware of any
number types where addition is non-commutative, but subtraction is
noncommutative even for integers, and noncommutative multiplication is
quite common (e.g. matrix multiplication).
And of course, once you start using floating point numbers, you can't assume
commutativity:
>>> 0.1 + 0.7 + 0.3 == 0.3 + 0.7 + 0.1
False
I'm reminded of this quote from John Baez:
"The real numbers are the dependable breadwinner of the family, the complete
ordered field we all rely on. The complex numbers are a slightly flashier
but still respectable younger brother: not ordered, but algebraically
complete. The quaternions, being noncommutative, are the eccentric cousin
who is shunned at important family gatherings. But the octonions are the
crazy old uncle nobody lets out of the attic: they are nonassociative."
(And don't even ask about the sedenions...)
--
Steven
More information about the Python-list
mailing list