Static member variables

Jerome Quelin jerome.quelin at insalien.org
Sun Jul 9 17:04:24 EDT 2000


"Thomas Svensson" <thomas_s at ebox.tninet.se> wrote:
>Is there a way of declaring static (and constant) member variables in
>classes? I have a member variable that should be unique for each class
>type and thus should not waste memory for each instance of the class I
>create. Something like the __doc__ string I guess.

And is it possible to have a static method (ie, a class method in C++ jargon) ?

>>> class t:
..  def t():
..   print "t.t"
>>> t.t()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: unbound method must be called with class instance 1st argument

But the t() method does not wait for any arguments...

Regards,
Jerome
--
jerome.quelin at insalien.org



More information about the Python-list mailing list