On 2017-10-19 10:11, ast wrote: > Surprisingly, __call__ from the class is called, not the > one defined in the object. Why ?
That's just how dunder methods like __call__ work. See https://docs.python.org/3/reference/datamodel.html#special-method-names To quote the docs: > For instance, if a class defines a method named __getitem__(), and x is an > instance of this class, then x[i] is roughly equivalent to > type(x).__getitem__(x, i). This is also true for __call__. In your case, calling test is more-or-less equivalent to getattr(type(test), '__call__')(test), NOT getattr(test, '__call__')(). -- Thomas Jollans -- https://mail.python.org/mailman/listinfo/python-list