[Tutor] classmethod, staticmethod functions (decorator related)

Steven D'Aprano steve at pearwood.info
Mon Sep 13 01:13:25 CEST 2010

On Mon, 13 Sep 2010 06:05:23 am Alan Gauld wrote:

> I think static methjods are largely a mistake of history. ISTR They
> were
> introduced into python before class methods (not by much - one
> release?)

No, they were introduced at the same time. But it turned out that the 
use cases Guido van Rossum envisaged for them weren't as compelling as 
he first imagined. At some point he wrote that staticmethod was the 
only Python feature where there was no example of it being used in the 
standard library, apart from tests to ensure that staticmethod worked 

Of course that doesn't mean that staticmethod is a bad feature, only 
that it's a very specialized function. It probably should have been 
moved into functools.

If anyone is interested in descriptors like classmethod and 
staticmethod, I have published a recipe for a third member of the 


"dualmethod" creates a method that receives the instance when you call 
it normally from the instance, and the class when you call it from the 
class. This makes it like a cross between ordinary methods and class 

Steven D'Aprano

More information about the Tutor mailing list