If I use from time import time, the Python 2.7.3 does not recognize time.sleep(60). But if I use import time, then Python does not recognize t=time(). Why does this happen? Is there any way I can use time() and time.sleep(x) in the same program?
from time import time
#import time
intervalInMinute = 1
t = time()
while 1:
time.sleep(60)
The kind of error I get is:
Traceback (most recent call last): File “myProg.py”, line 9, in
time.sleep(60) AttributeError: ‘builtin_function_or_method’ object has no attribute ‘sleep’
You need to decide what you want the name
timeto refer to, the module or the function calledtimein the module. You can write:or