Python is not a message-based OO system 1 . Instead, like JavaScript, properties are resolved for first-class functions, and then called; The behavior is slightly different in mechanics such as those found.
In Python, the requirement is that methods have at least one parameter, usually called self , that will be automatically passed by the associated instance when it is called as a method.
Additionally (and possibly to the point of the question), Python does not distinguish between using def f.. or f = some_func() when setting the bindings of instance elements; perhaps this corresponds to behavior outside of classes.
In this example, assigning a function to an instance "makes it wait for processing as an instance method." This is the same — without parameters — a function called in both cases; only appropriate future use matters.
Now, unlike JavaScript, Python processes methods and object associations through the concept of related methods — functions that are allowed as methods are always “connected”.
The af behavior, which returns the bound function, which automatically passes the bound object to the first parameter as self is executed regardless of the source of the function. In this case, this means that a function without parameters cannot be used when it is “connected”, because it does not accept the self parameter.
As a demonstration, the following will crash in the same way, since the original base method does not meet the minimum requirements for taking an instance as an argument:
g = af g()
In this case, calling g() equivalent to calling func(a) .
1 For comparison, Java, C #, Ruby, and SmallTalk are message-based OO systems - this object suggests invoking a method by name, rather than allowing a method (or function) as a value that can be called.