I was trying to use threading in my python program and as I am new in python I need to learn the Threading. I was googling for a quick example of python threading and I found the following program from here.
import threading
import datetime
class ThreadClass(threading.Thread):
def run(self):
now = datetime.datetime.now()
print "%s says Hello World at time: %s" %(self.getName(), now)
for i in range(2):
t = ThreadClass()
t.start()
When I run it, its give the following error:
Traceback (most recent call last):
File "threading.py", line 1, in
import threading
File "/home/murtoza/pyro/threading.py", line 4, in
class ThreadClass(threading.Thread):
AttributeError: 'module' object has no attribute 'Thread'
I just copy the code from the net, and it should run perfectly but why its not running!!! Whats the problem in the code? I had no idea. I googled by the keyword “AttributeError: 'module' object has no attribute 'Thread'” and found this. Its the same error, same OS. And I got the solution in the second page.
What I did? I coped the code from net, made a file named threading.py and pasted the code. Then run it by $ python threading.py command. The compiler got confused. The first line of the
No comments:
Post a Comment