Reputation: 1275
I'm trying to import the threading module, however, i just seem to get errors for no good reason. Here is my code:
import threading
class TheThread ( threading.Thread ):
def run ( self ):
print 'Insert some thread stuff here.'
print 'I\'ll be executed...yeah....'
print 'There\'s not much to it.'
TheThread.Start()
And the errors:
Traceback (most recent call last):
File "threading.py", line 1, in <module>
import threading
File "C:\Users\Trent\Documents\Scripting\Python\Threading\threading.py", line
3, in <module>
class TheThread ( threading.Thread ):
AttributeError: 'module' object has no attribute 'Thread'
Press any key to continue . . .
Python stats:
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32
Upvotes: 15
Views: 17448
Reputation: 1
I think you used threading name to your current working file.Change your file name with different name.It will work.It works for me too
Upvotes: 0
Reputation: 18850
First, you have to rename your own file: It is called threading.py and since it is in the Python Path it replaces the threading module of the standard Python library.
Second, you have to create an instance of your thread-class:
TheThread().start() # start with latter case
Upvotes: 4
Reputation: 1169
i think that all you need is just to rename the name of your working file, because your file name is the same as module name:
threading.py
or you have wrong threading.py file in your working directory
Upvotes: 57