Callable or not callable, that is the question!

Ulrich Eckhardt ulrich.eckhardt at
Thu Jul 11 15:05:59 CEST 2013


I just stumbled over a case where Python (2.7 and 3.3 on MS Windows) 
fail to detect that an object is a function, using the callable() 
builtin function. Investigating, I found out that the object was indeed 
not callable, but in a way that was very unexpected to me:

     class X:
         def example():
         test1 = example
         test2 = [example,]

     X.example() # OK
     X.test1() # OK
     X.test2[0]() # TypeError: 'staticmethod' object is not callable

Bug or feature?



More information about the Python-list mailing list