Behavior of staticmethod in Python 3

Ian Kelly ian.g.kelly at
Sun Nov 24 11:45:02 CET 2013

On Sun, Nov 24, 2013 at 3:30 AM, Antoon Pardon
<antoon.pardon at> wrote:
> Op 23-11-13 22:51, Peter Otten schreef:
>> Antoon Pardon wrote:
>>> Op 23-11-13 10:01, Peter Otten schreef:
>>>> Your script is saying that a staticmethod instance is not a callable
>>>> object. It need not be because
>>>> doesn't call the attribute directly, it calls
>>>>, Foo)()
>>> I think you are burdening the programmer with implemantation details
>>> that don't matter to him.
>>> IMO if is legal then is callable. That the actual call
>>> is delegated to, Foo) shouldn't matter.
>> If you read the original post -- I think in this case the details do matter.
>> What is your highlevel explanation for
> I don't care about what kind of explanation. I care about a correct answer to
> the question whether a particular object is callable (from a programmers point
> of view). I'm sure you can give a very comprehensive explanation for why in
> this case we get an incorrect answer but that doesn't make the behaviour correct.
> is legal here. So is callable. So you starting with it needn't
> be callable is using "callable" with a different meaning than the natural
> interpretation. Al the rest is just an attempt in getting others to accept your
> use of "callable" instead of the natural one.
> being legal and not being callable is IMO a bug in python. No matter
> what explanation you have for the behaviour.

Your supposition that is not considered callable by Python is
false, as Chris already demonstrated, and I don't see where anybody
here has stated otherwise.  What Peter wrote was that "a staticmethod
instance is not a callable object", which is absolutely correct, and
these two facts are consistent because is not a staticmethod
instance (Foo.__dict__['foo'] on the other hand *is* a staticmethod
instance and *is not* callable, and Foo.__dict__['foo']() will
correspondingly raise a TypeError).

More information about the Python-list mailing list