Running a python script for a user-specified amount of time?
- by Rob
Sorry, this is probably a terrible question. I've JUST started learning python today. I've been reading a Byte of Python. Right now I have a project for Python that involves time. I can't find anything relating to time in Byte of Python, so I'll ask you:
How can I run a block for a user specified amount of time and then break?
For example (in some pseudo-code):
time = int(raw_input('Enter the amount of seconds you want to run this: '))
while there is still time left:
#run this block
or even better:
import sys
time = sys.argv[1]
while there is still time left:
#run this block
Thanks for any help. Also, additional online guides and tutorials would be much appreciated. I really like Byte of Python. Dive into Python can't quite hold my attention, though. I suppose I should suck it up and try harder to read that one.