where are the "class variables"?

Dominik Kaspar dokaspar at student.ethz.ch
Tue Sep 30 22:27:15 CEST 2003


maybe my question was badly formulated. i give it a new try:
why does the following program give the output "0 0" and not "1 0"?
why does it loop forever? and how could that problem be fixed?

import threading

class Server(threading.Thread):
    running = 0
    
    def run(self):
        running = 1
        while running:
            print "do something here..."
            
    def stop(self):
        running = 0

server = Server()
server.start()
print server.running        # should print "1"
server.stop()
print server.running        # should print "0"




More information about the Python-list mailing list