sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

-a should translate to a.__neg__() instead of Number(-1).__mul__(a) #98

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. a=object()
2. print(-a)
3.

What is the expected output? 
if __neg__ is defined for the object, it should return a value
(ie, the above should be translated to  a.__neg__()) instead of how it is 
translated:
Number(-1).__mul__(a)

Number.__mul__ would have to "know" how to work with each type of object, even 
newly defined ones.

What do you see instead?

Please use labels and text to provide additional information.

Original issue reported on code.google.com by billy.earney@gmail.com on 10 Mar 2013 at 12:59