[Python-ideas] Left division operator

Nick Coghlan ncoghlan at gmail.com
Sun Jul 17 09:22:29 CEST 2011


On Sun, Jul 17, 2011 at 5:16 AM, Sturla Molden <sturla at molden.no> wrote:
> I was wondering if anyone else has felt the need for a leftward division
> operator in Python. That is, y\x in addition to x/y. Thus the operators:
>
>   y \ x
>   y \\ x
>
> Why the statement "y\x" is different from "x/y":
>
> 1. Opposite order of evaluation: This is important if evaluating one of the
> operands has side-effects.

1. Python evaluates operands in left to right fashion. Breaking this
requires extremely good justification (The ternary operator is the
only current exception that doesn't involve a closure, and that's only
because the alternatives were all even worse).

2. Backslash is not a viable operator choice. Ever. (cf. Carl's answer)

3. The use case is far too narrow to be baked into the core language.
If it's beyond high school mathematics, syntactic support within
expressions is highly unlikely to ever be provided.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list