[Python-ideas] Left division operator

MRAB python at mrabarnett.plus.com
Mon Jul 18 00:39:52 CEST 2011


On 17/07/2011 18:05, Sturla Molden wrote:
> Den 17.07.2011 18:27, skrev Steven D'Aprano:
>>>> tmp = denominator() # Evaluate this first, because it has side-effects.
>> result = numerator()/tmp
>> The order of the arguments is lost to the division operator.
>>>>> you can write this:
>>>> result = denominator()\numerator()
>> Only for real numbers.
>> result = denominator()\numerator()
>> would be equivalent to
>> tmp = 1/denominator()
> result = tmp * numerator()
>> But please ignore this suggestion, I agree that it is a bad suggestion.
>> There is a better solution for this particular problem, which is to make
> 1/x return a new type, so that (1/x)*y evalutes differenty from y*(1/x).
> So I am thinking of suggesting addition of an "inverted matrix" type to
> NumPy instead.
>If there's a reverse division operator, then why not a reverse
subtraction operator too? Or a reverse modulo operator?


More information about the Python-ideas mailing list

AltStyle によって変換されたページ (->オリジナル) /