Alex Rivera | Logout

operator overloading in python

Asked 2009-12-20T15:32:08.677
45

Possible Duplicates:
Python: defining my own operators?
Rules of thumb for when to use operator overloading in python

Is it possible to overload operators in Python? If so, can one define new operators, such as ++ and <<?

Edit
Report

1 Answer

6

See: http://docs.python.org/reference/datamodel.html#special-method-names.

A class can implement certain operations that are invoked by special syntax (such as arithmetic operations or subscripting and slicing) by defining methods with special names. This is Python’s approach to operator overloading, allowing classes to define their own behavior with respect to language operators.

answered 2009-12-20T15:35:43.047

Your Answer