where are the "class variables"?

Gerrit Holl gerrit at nl.linux.org
Tue Sep 30 15:19:04 EDT 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

This is where self is for: self.running refers to the class
variable 'running'.

Gerrit.

-- 
249. If any one hire an ox, and God strike it that it die, the man who
hired it shall swear by God and be considered guiltless.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list