static class methods in Python?

Gordon McMillan gmcm at
Thu Feb 17 22:57:54 EST 2000

Greg Wilson asks:
> Have there been any proposals to add the equivalent of "static"
> methods (belonging to the class, not to instances) to Python?

The complaints vastly outnumber the proposals.

The most common complaint is the lack of C++ style static 
methods. These are usually greeted with hordes of ugly 
workarounds. But the argument for is largely aesthetic, (since 
a module level function serves the same purpose), and 
supporting this in Python would mean some way of flagging a 
function living in a class's dict as being something that should 
not be bound on a getattr, (since a normal method actually 
*is* a function object living in a class dict).

Then there are a few who want Smalltalk style "class 
methods", which take a "self", but the "self" is the class 
object, not the instance. Don Beaudry actually did this as part 
of his MESS / objectmodule experiments, but they broke with 
Python 1.5.

- Gordon

More information about the Python-list mailing list