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
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):
>
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
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
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
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