7/26/2026 at 11:13:37 AM
So the `+` is not _overloaded_, the `+` syntax is a shorthand for calling a method named `__add__` on the value of the first operand, with the value of the second operand as an argument . That is: `e1 + e2` is syntactic sugar for `e1.__add__(e2)`, no more and no less.It's not "operator overloading" any more than two _different_ classes having a `length` property is "length overloading".
Using the term "operator overloading" to begin with is the error here.
by reichstein
7/26/2026 at 2:05:00 PM
I think the bigger problem here is that "overloading" is specifically about providing multiple functions with the same name that take different parameters. You cannot truly overload in python, partly because it is weakly typed, and mostly because function names are a key in attribute dictionaries and must be unique.The article is showing function overriding, not overloading, which is just standard class inheritance stuff.
by AkBKukU
7/26/2026 at 12:46:57 PM
If + silently gets translated to adding 2 numbers or joining 2 strings that is operator overloading, no matter how it's done under the hood.If python had you write e1.__add__(e2) Or S1.__join__(s2)
Then you would have 2 distinct operators, therefore no overloading.
Re classes.
Foo.len() and bar.len() are different. You can tell that when you are using them.
It's no different to I_add() and f_add() they are both different functions.
If you automatically called one of those depending on whether the arguments were floats or ints, that would be overloading.
I suppose you could take it further and say that it's overloading if you have different int sizes.
But then we don't really class that as overloading, which I suppose demonstrates that it isn't a very precise term so there isn't much point getting particularly pedantic about it.
by benj111