[Tutor] Class vs. Static Methods
Chinook
chinook.nr at tds.net
Tue Jun 21 23:28:48 CEST 2005
On Tue, 21 Jun 2005 16:52:09 -0400, Chuck Allison wrote
(in article <10110159435.20050621145209 at freshsources.com>):
> Sorry for the elementary question: I was wondering if someone could
> explain the difference to me between class and static methods. Coming
> from other languages, I'm used to static methods, but not "class
> methods". Thanks.
>
>
Does this help (from the QR)?
Static methods : Use staticmethod(f) to make method f(x) static (unbound).
Class methods: like a static but takes the Class as 1st argument => Use f =
classmethod(f) to make method f(theClass, x) a class method.
The decorators @staticmethod and @classmethod replace more elegantly the
equivalent declarations f = staticmethod(f) and f = classmethod(f).
Lee C
More information about the Tutor
mailing list