[Edu-sig] Class methods in 2.2a2

Kirby Urner urnerk@qwest.net
Sun, 26 Aug 2001 23:41:09 -0400


Self-less classes:  it's now possible to define methods with no self
argument.  The methods may be invoked even with no instance of
the class being created:

>>> class foo:
...   def add(a,b):
...     return a+b
...   add = staticmethod(add)
...

>>> foo.add(3,4)
7
>>> g = foo()
>>> g.add(1,2)
3

Yes, I've been reading the PEPs -- obviously.  E.g.:
http://python.sourceforge.net/peps/pep-0253.html

Kirby