On Sat, Apr 18, 2015 at 5:42 AM, Joao S. O. Bueno <jsbueno@python.org.br> wrote:
On 17 April 2015 at 18:39, Guido van Rossum <guido@python.org> wrote:
I think you've found an unintended and undocumented backdoor. I admit I don't understand how this works in CPython. Overloaded operators like __add__ or __call__ should be methods in the class, and we don't look for them in the instance. But somehow defining them with @property works (I guess because @property is in the class).
What's different for __call__ is that callable() exists. And this is probably why I exorcised it Python 3.0 -- but apparently it's back. :-(
And for much that I've searched I've never found out the reasoning on that exorcism. Since you are at it, could you describe it?
I am glad it is back - I think it is definitely needed - even if just works in a sort of naive way.
Glad you asked. The reason for the exorcism was actually the kind of issues brought up in this thread -- there are a variety of edge cases where an object may in fact be called but callable() returns False, and other edge cases where callable() returns True but calling the object fails. (Not to mention that callable() says nothing about the acceptable arguments.) Not having callable() would have avoided this entire thread. -- --Guido van Rossum (python.org/~guido)