overloading operators

Alex Martelli aleax at aleax.it
Thu Jan 24 05:21:23 EST 2002


"QdlatY" <qdlaty at ikom.pl> wrote in message
news:Xns91A0418F84Aqdlatywielundhsorg at 153.19.253.204...
> Hello
>
> Is it possible to overload an operator in python (for objects) ?

Yes, see http://www.python.org/doc/current/ref/specialnames.html .

Basically, you can define a method named __add__ to 'overload' operator +,
one named __mul__ to overload operator *, and so on.


Alex






More information about the Python-list mailing list