The documentation actually provides an example very similar to yours. In the description of "Method Objects" :
When an instance attribute is specified that is not a data attribute, its class is executed. If the name indicates a valid class attribute that is a function object, a method object is created by packing (pointers to) an instance object and a function object just found together in an abstract object: this is a method object.
and Random remarks :
There is no need for a function definition to be embedded in the text in the class definition: assigning the function object to a local variable in the class is also normal.
The last quote is followed by an example to which I refer.
Basically, the idea is that any function named in a class definition becomes a method of that class. Since you are not instantiating the class, your method is never bound to the instance object (hence ... unbound method Bar() ... ). Methods are always called with the first parameter containing the object to which they call, whether you like it or not.
That's why you, by the way, need a special decorator for @classmethod . The decorator wraps the function you created to give it the necessary interface, but pass the class object instead of the instance object to the wrapped function you specified.
Since your second version creates _callback as a data object, it simply saves the regular function pointer in the list and calls it as-is.
If you try to pass something like None to Foo._callback(None) , you will get rid of the original error that you get, but, of course, then there was no expectation of a transmission problem in the function parameter. You can work around this problem by providing Bar argument (which you ignore in this case):
def Bar(self): print "Called"
Mad physicist
source share