Python Operator Overloading

I was reading up on Django F() and Q(). I didn’t know Python had operator overloading. They call it magic methods.

Magic Methods on Rafe Kettler

There’s a pretty good tutorial at Treehouse.

But… a few memories of arguments about operator overloading surfaced, so I had to think about why Java rejected adding the feature to Java.

Oh yeah, here’s a good overview of right and wrong ways to use and abuse operators.

It looks like Python’s doing it by treating operators like syntactic sugar to dispatch magic methods. Good. Infix-to-s-expressions is a good thing.