where are the "class variables"?
John Roth
newsgroups at jhrothjr.com
Tue Sep 30 16:01:46 EDT 2003
"Dominik Kaspar" <dokaspar at student.ethz.ch> wrote in message
news:62e9c66e.0309301057.65f24a3b at posting.google.com...
> 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 (??)
This is correct - it binds 0 to the identifier running in the class.
>
> def run(self):
> running = 1
use Server.running
> while running:
use while Server.running:
> print "do something here..."
>
> def exit(self):
> running = 0
use Server.running
>
> thanks
> -- dominik
If you want to put an identifier in the class, reference the
class directly, or inherit from object and use a class method.
John Roth
More information about the Python-list
mailing list