Static class methods

Marcin 'Qrczak' Kowalczyk qrczak at
Mon Mar 5 17:26:20 CET 2001

Mon, 5 Mar 2001 01:06:06 +0100, Sven Peters <svpeters at> pisze:

> You CAN have class methods:
> def bert:
>         print "Bert"
> class.method = bert
> class.method()
> "Bert"

You can't. The first line is a syntax error. And the following:

class C: pass
def bert(): print "Bert"
C.method = bert

produces an error (unbound method must be called with class instance
1st argument).

I proposed a language change which allows class methods in a thread
titled "An alternative approach to bound methods" two weeks ago.
With this proposal the above would work, as well as putting the
function definition directly in the class.

 __("<  Marcin Kowalczyk * qrczak at
  ^^                      SYGNATURA ZASTĘPCZA

More information about the Python-list mailing list