Accessing thread variables
Lukas Kubin
kubin at opf.slu.cz
Wed Feb 19 05:21:31 EST 2003
What's the best way to access a thread's variable?
Let's say I have thread:
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.varToReturn = ""
self.start()
def run(self):
self.varToReturn = myAction()
def myAction():
string = "hello"
return string
And I call the thread:
i = MyThread()
print i.varToReturn
This returns nothing (the empty string) instead of "hello".
What am I doing bad?
Thank you.
lukas
More information about the Python-list
mailing list