[Python-Dev] Making staticmethod objects callable?

Nicolas Fleury nidoizo at yahoo.com
Wed Mar 1 15:57:12 CET 2006


Hi,

I've posted this question on comp.lang.python, but nobody seems to 
conclude it is a bad idea, so I post it here.
http://groups.google.com/group/comp.lang.python/browse_frm/thread/6082dae1deef9161/88bb8a26750dd8c6?lnk=raot&hl=en#88bb8a26750dd8c6

Basically, should staticmethods be made callable so that the following 
would not raise an exception:

class A:
     @staticmethod
     def foo(): pass
     bar = foo()

There's workarounds, but it's really just about usability.  staticmethod 
could still return a descriptor, but additionnally callable.  Is there 
something I'm missing?  Is it error-prone in any way?

Note that I'm not a big fan of static methods myself, but I understand 
users expecting this work.

Regards,
Nicolas



More information about the Python-Dev mailing list