[Tutor] The time and clock functions

Jeff Shannon jeff@ccvcorp.com
Mon Jun 23 16:14:02 2003


Abel Daniel wrote:

>>When I am in IDLE,  I can't get the time() or clock() functions to work. 
>>Can someone provide a code snippet I can use???  I thought they were
>>built-in and didn't require anything more than just invoking them. 
>>Thanks.
>>    
>>
>They are in the module named 'time', so you need to 'import time' first.
>(or 'from time import time, clock' if you want to call them as time()
>and clock() and not as time.time() and time.clock(). )
>

But note that if you use 'from time import time', you'll then have 
difficulty accessing any other functions in the time module.  Since 
you've taken the name 'time' for just the single function, you can no 
longer access the module by the name 'time'.  This may not be an issue 
in a given script, but it's something to be aware of.

Jeff Shannon
Technician/Programmer
Credit International