can I overload operators like "=>", "->" or something like that?

alex23 wuwei23 at gmail.com
Fri Apr 20 00:38:28 EDT 2012


On Apr 20, 5:54 am, Jacob MacDonald <jaccar... at gmail.com> wrote:

> On Thursday, April 19, 2012 12:28:50 PM UTC-7, dmitrey wrote:
> > can I somehow overload operators like "=>", "->" or something like
> > that?

> I don't believe that you could overload those particular operators,
> since to my knowledge they do not exist in Python to begin with.

It all depends on if the operators use special methods on objects:
http://docs.python.org/reference/datamodel.html#special-method-names

You can overload => via object.__le__, for example.



More information about the Python-list mailing list