Stupid q: Where is the destructor?
Martin von Loewis
loewis at informatik.hu-berlin.de
Tue Aug 29 08:01:55 EDT 2000
Kjell Kolsaker <kjell.kolsaker at kkt.ntnu.no> writes:
> Another question: Static methods?
>
> # Simple sample...
>
> >>> class foo:
> ... i=12
> ... def getI():
> ... return foo.i
> ...
> >>> print foo.getI()
> Traceback (innermost last):
> File "<interactive input>", line 1, in ?
> TypeError: unbound method must be called with class instance 1st argument
> >>>
>
> I have tried to define a static method, where it has no sense to pass
> a self parameter. My try doesn't work. Why?
Python does not provide class methods. If you absolutely think you
need them, please have a look at
http://x58.deja.com/[ST_rn=ps]/getdoc.xp?AN=650168200&CONTEXT=967549920.748617756&hitnum=6
There is a number of other strategies as well; the basic idea is that
a class method is really a callable object, which must not turn into an
unbound method when accessed through the class.
Regards,
Martin
More information about the Python-list
mailing list