Skip to content Skip to sidebar Skip to footer

Python Functions And Their __call__ Attribute

I am using Python 2.7.2. I want to understand the relationship between calling a function and calling the __call__ attribute of the function. For example, consider the following

Solution 1:

I recommend you read special method lookup for new-style classes (especially the last paragraph).

For new-style classes, implicit invocations of special methods are only guaranteed to work correctly if defined on an object’s type, not in the object’s instance dictionary.

Post a Comment for "Python Functions And Their __call__ Attribute"