[Python-Dev] Making staticmethod objects callable?
nidoizo at yahoo.com
Thu Mar 2 07:55:03 CET 2006
Guido van Rossum wrote:
> In which context did you find a need for defining a static method and
> calling it inside the class definition? I'm guessing that what you're
> playing dubious scoping games.
I'm not. I almost never use staticmethod actually. I find them not
very pythonic, in my humble own definition of pythonic.
But since staticmethod is a standard built-in, I considered valid the
question of a programmer relatively new to Python (but obviously
appreciating its dynamic nature) wondering why calling a static method
inside a class definition doesn't work. A use case is not hard to
imagine, especially a private static method called only to build a class
I don't know the philosophy behind making staticmethod a built-in
(instead of a function in a module only used in specific occasions), but
my guess was that what is normal scoping/regrouping in Java/C++/C# was
worth common use support in Python. But your comment about "dubious
scoping games" makes me think I, again, didn't guess right;)
So yes, I'm proposing something I'll probably never use, but I think
would make Python more "welcoming".
More information about the Python-Dev