PEP 8 example of 'Function and method arguments'

Duncan Booth duncan.booth at invalid.invalid
Tue Mar 14 09:55:52 CET 2006

Terry Hancock wrote:

> So far, the only time I've ever encountered this is with the
> __new__ method, which, being a classmethod, needs "cls"
> (which gets loaded with the *class* not the *instance*).

The __new__ method isn't actually a classmethod. In, GvR wrote:

> Factoid: __new__ is a static method, not a class method. I initially
> thought it would have to be a class method, and that's why I added the
> classmethod primitive. Unfortunately, with class methods, upcalls
> don't work right in this case, so I had to make it a static method
> with an explicit class as its first argument. Ironically, there are
> now no known uses for class methods in the Python distribution (other
> than in the test suite). However, class methods are still useful in
> other places, for example, to program inheritable alternate
> constructors. 

More information about the Python-list mailing list