class variables

Oleg Broytmann phd at phd.russ.ru
Fri Mar 10 05:12:25 EST 2000


On Fri, 10 Mar 2000 T.Rafie at ALCATEL.de wrote:
> In C++ one can use static variables as class variables on which You have
> access
> from different instances of the class.  How can that be realized in
> Python?

class Pluss:
   botherMe = 1

   def __init__(self):
      self.word = 1

   def do(self):
      print self.word

p = Pluss()
print pluss.botherMe
print Pluss.botherMe

Oleg.
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list