Re: [Python-Dev] summing integer and class

2013-10-03 Thread Greg Ewing
Igor Vasilyev wrote: class A(): def __add__(self, var): print("I'm in A class") return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last): File "../../test.py", line 7, in 1+a TypeError: unsupported operand type(s) for +: 'int

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Chris Kaynor
This list is for development OF Python, not for development in python. For that reason, I will redirect this to python-list as well. My actual answer is below. On Thu, Oct 3, 2013 at 6:45 AM, Igor Vasilyev wrote: > Hi. > > Example test.py: > > class A(): > def __add__(self, var): >

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Xavier Morel
On 2013-10-03, at 15:45 , Igor Vasilyev wrote: > Hi. > > Example test.py: > > class A(): >def __add__(self, var): >print("I'm in A class") >return 5 > a = A() > a+1 > 1+a > > Execution: > python test.py > I'm in A class > Traceback (most recent call last): > File "../../te

Re: [Python-Dev] summing integer and class

2013-10-03 Thread Chris Angelico
On Thu, Oct 3, 2013 at 11:09 PM, Игорь Васильев wrote: > When we adding class to integer we have both slotv and slotw. x = slotv(v, > w); -> returns Py_NotImplemented. > But in this case we should execute x = slotw(v, w); and function should be > completed in the same way as when we adding integer

[Python-Dev] summing integer and class

2013-10-03 Thread Игорь Васильев
Hi. Example test.py: class A():     def __add__(self, var):     print("I'm in A class")     return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last):   File "../../test.py", line 7, in     1+a TypeError: unsupported operand type(s) for +: 'in

[Python-Dev] summing integer and class

2013-10-03 Thread Igor Vasilyev
Hi. Example test.py: class A(): def __add__(self, var): print("I'm in A class") return 5 a = A() a+1 1+a Execution: python test.py I'm in A class Traceback (most recent call last): File "../../test.py", line 7, in 1+a TypeError: unsupported operand type(s) for +: 'int