Ive looked many places but the answer to this question has eluded me, once a script is executed how can you make it so that it re-starts.

Oh, and what is the meaning of life?:cheesy:

Make the last line of the script run the script :)

Oh, I'm sorry. I confused the answer to your question with the best way to get runaway processes.

You put program code in a loop and designate one key to break out of loop:

while True:
    
    # this is an example of your program:
    print
    print "My program!  Really!"
    print
    
    choice = raw_input("Enter r (repeat) or q (quit): ")
    if 'q' in choice:
        break  # exits the while loop, any other key repeats loop

Here is another example how to do this, as suggested by cscgal ...

# save this code as endless.py

password = raw_input("I am running almost endlessly unless you enter the secret password: ")
if 'q' in password:
    raise SystemExit, "I am quitting now ..."

execfile("endless.py")

Notice how the ultimate escape has been accomplished.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.