difference between class methods and instance methods
Terry Reedy
tjreedy at udel.edu
Thu Feb 17 14:49:04 EST 2005
"John M. Gabriele" <john_sips_teaz at yahooz.com> wrote in message
news:pan.2005.02.17.07.04.37.907754 at yahooz.com...
> And if anyone's *really* daring:
> Where do the so-called "static methods" fit into all this?
> By the name of them, it sounds like the same thing as class
> methods...
No, not at all. So called 'static methods' are class function attibutes
that are marked to *not* be given neither the method wrapping treatment nor
the first-arg binding treatment when accessed, but to be left as they are.
To me, this means that they are not methods but just functions.
>>> class C:
... def f(): pass
... def g(): pass
... g = staticmethod(g)
...
>>> C.f
<unbound method C.f>
>>> C.g
<function g at 0x00888978>
Terry J. Reedy
More information about the Python-list
mailing list