where are the "class variables"?

Bob Gailer bgailer at alum.rpi.edu
Tue Sep 30 15:03:28 EDT 2003


At 12:57 PM 9/30/2003, Dominik Kaspar wrote:

>i'm used to java and its strict way of defining variables. so how is
>it possible to reach something like a class variable in python?
>with the following code i didn't have much succes...
>
>class Server(threading.Thread):
>     running = 0  (??)
>
>     def run(self):
>         running = 1
>         while running:
>             print "do something here..."
>     def exit(self):
>         running = 0

prefix running with the class name:
           Server.running =1
           while Server.running:
         ...
          Server.running = 0

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003


More information about the Python-list mailing list