Reputation: 73
I run a piece of code on my mac in IDLE and it works fine. But when I tried to run the same code on a linux machine from the command line it gave me this error:
Traceback (most recent call last):
File "time.py", line 1, in <module>
import time
File "/home/ugrad/user/time.py", line 3, in <module>
t1 = time.time()
TypeError: 'module' object is not callable
here is the code:
import time
t1 = time.time()
size = 10000000
for i in range(size):
a = i
a += 100
a *= 35
val = (a == 839248637)
t2 = time.time()
res = t2-t1
print(res)
What am I doing wrong here?
Upvotes: 2
Views: 1164
Reputation: 143097
You named your file time.py
so now import time
loads your file instead Python time
module. Change name to different - ie. time-test.py
Upvotes: 3