You are just a little confused about imports.
If I >>> import time
then the name 'time' is bound to the time module: >>> time <module 'time' (built-in)>
The time() function is an attribute of the time module: >>> time.time <built-in function time> >>> time.time() 1112296322.9560001
Alternatively, I can import the time function directly: >>> from time import time
Now the name 'time' is bound to the time() function: >>> time <built-in function time> >>> time() 1112296332.8610001
and time.time gives an error: >>> time.time Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'builtin_function_or_method' object has no attribute 'time'
When you say 'from time import *' that means bring *all* the names from the time module into the current namespace. It's like saying
from time import accept2dyear
from time import altzone
from time import asctime
...
from time import time
...
so then when you try to access time.time you get the AttributeError.
Kent
John Carmona wrote:
Alan and John thanks for the help. I have now this bit of script but it is not running.
----------------------------------------------------------------------------------------------------------
from time import *
n = time() s = str(n) numb = s[-2:] # last two characters of the string numb = int(numb) # convert back to a number guess = (raw_input('Enter a number: '))
if guess == numb: print ("Bravo, you have just won the right to play again!")
elif guess < numb: print "You are just a bit too low, try again"
else: print "You are just a bit too high, try again"
print "The End"
----------------------------------------------------------------------------------------------------------
If i write the following line: "n = time.time()
I get the following error message:
---------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Python24/Example/high_lowtest.py", line 3, in -toplevel-
n = time.time()
AttributeError: 'builtin_function_or_method' object has no attribute 'time'
--------------------------------------------------------------------------------------------------------
I feel like an idiot asking what is probably very basics questions but my desire to learn is quite high right now and I don't want to lose it, thanks again
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor