Comprehensive guide to Operator Overloading in Python [closed]

Python’s operator overloading is done by redefining certain special methods in any class.
This is explained in the Python language reference.

For example, to overload the addition operator:

>>> class MyClass(object):
...     def __add__(self, x):
...         return '%s plus %s' % (self, x)
... 
>>> obj = MyClass()
>>> obj + 1
'<__main__.MyClass object at 0xb77eff2c> plus 1'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)