[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power
Steven D'Aprano
steve at pearwood.info
Sat Mar 15 14:47:37 CET 2014
On Sat, Mar 15, 2014 at 12:42:51PM +0000, Oscar Benjamin wrote:
> Just to add to that: I personally would almost always use brackets
> rather than rely on left- or right- associativity for something like
> this.
> A similar way that it can come up is with scalar-scalar vs
> scalar-array multiplication e.g.:
>
> 2 * pi * x / L * A # A is a big array
>
> I would rewrite that as
>
> (2 * pi * x / L) * A
>
> rather than rely on precedence/associativity.
It seems to me that you actually are relying on precedence/
associativity, otherwise you would have written it in fully-bracketed
form like this:
(((2 * pi) * x) / L) * A
It's your choice to include redundant brackets in an expression, but I
try hard to avoid the extra visual noise.
--
Steven
More information about the Python-ideas
mailing list