7 ms·
Wait, what? Python doesn't have single dispatch? How does it pick which block of code to run when you say a.f(x)? That dispatches on the class of a doesn't it?
by omaranto 14y ago
Wait, what? Python doesn't have single dispatch? How does it pick which block of code to run when you say a.f(x)? That dispatches on the class of a doesn't it?
- skittles 14y agoYou're correct. Python objects have methods that explicitly take "self" as the first argument. In Java and C#, self or "this" is implied. They all are single-dispatch languages unless an add-on library is used.
- martincmartin 14y agoYeah you're right. My bad, I was thinking of f(x, y). a.f(x) is single dispatch - just like C++ and Java.