Re:A Guide to Python's Magic Methods (2012)
by int_19h on Thursday August 09, 2018 @05:32PM
(#17728687)
In Python, though, operator overloading is not merely "supported". It's how all operators are defined, including built-in ones.
Which is a good thing, because it makes the whole arrangement a lot more consistent that languages in which this sort of thing is just magic associated with a specific primitive type (sometimes it's even inconsistent - e.g. in C#, + for ints and strings is magic, but + for decimal is an overloaded operator). In Python, all that magic is confined to the magic methods. Learn them once, and they work the same everywhere.
[ Parent
| on HN ]
There are no comments on this comment yet.