[Python-Dev] Making staticmethod objects callable?

Nicolas Fleury nidoizo at yahoo.com
Thu Mar 16 23:58:27 CET 2006


Guido van Rossum wrote:
> There's no need to change Python so that people coming from other
> languages won't make silly mistakes, is there?

Is that really a mistake...  Yes, it's a mistake since staticmethod is a 
descriptor, but isn't it in a sense an implementation detail, 
particularly for a newbie?  As Steven pointed, it is forcing to learn 
about descriptors.  But I don't feel comfortable with that; I've always 
seen Python as a language that you can use with minimal knowledge. 
Again, I'm not thinking about anyone on this list.

> BTW I question the claimed reflex -- assuming by "other languages" you
> mean Java or C++ (the only languages I know that *have* static
> methods) -- since those languages don't have the ability to call
> methods (static or otherwise) at class definition time.

Java, C++, C#.  Yes, you're right, but the way I see it the first thing 
you learn in Python is that everything is dynamic.  So I understand the 
reflex to quickly adapt the way you code to the new capabilities of Python.

> So perhaps you need to dig deeper to find out *why* this is a recurring issue.

I think I understand why this is a recurring issue, but maybe I'm not 
good at explaining why.  In the end, on that specific issue I think 
there's something to improve for newbies.  The error message 
"'staticmethod' object is not callable" could also be changed to 
something like "'staticmethod' object is a descriptor and is not 
callable".  Personally, I prefer the "it just works to ease your life" 
compromise (it doesn't hurt much, no?).

Note that it's not a big deal anyway and I hope it doesn't look like I 
want to argue; I just want to explain the issue.

Regards,
Nicolas



More information about the Python-Dev mailing list