About 1,720,000 results
Open links in new tab
  1. python - How do I restart a program based on user input

    You can simply nest the entire program in a user-defined function (Of course you must give everything inside an extra indent) and have it restart at anytime using this line of code: …

  2. How to restart a python script after it finishes

    Mar 27, 2014 · I have a python script that will be running that basically collects data and inserts it into a database based on the last time the database was updated. Basically, i want this script …

  3. How do I re-run code in Python? - Stack Overflow

    Jul 12, 2012 · You need to bury the code block in another code block. Follow the instructions below: Step 1: Top of code def main() Step 2: restart = input("Do you want to play a …

  4. How to restart a Python Script [6 Simple Ways] - bobbyhadz

    Apr 13, 2024 · The code sample uses the os.execv() method to restart the Python script. The sys.executable property returns a string that stores the absolute path of the executable binary …

  5. How to Restart a Python Program Successfully - Python Mania

    When a program needs to refresh entirely, like reloading configurations or resetting variables, os.execv () or subprocess.run () can restart the script as if it’s being launched anew—all …

  6. How Can You Effectively Restart Your Code in Python?

    Learn how to restart your Python code efficiently with our easy-to-follow guide. Discover various methods, including using functions and control structures, to reset your scripts without starting …

  7. How to Restart Python Scripts | Tutorial Reference

    This guide explains different methods to restart a Python script, emphasizing the recommended approach (os.execv()) and outlining the pros and cons of alternatives. Restarting with …

  8. Top 5 Methods to Restart a Python Script from Within Itself

    Nov 24, 2024 · One of the most reliable methods to restart your Python script is by leveraging the os.execv() function from Python’s os module. This command replaces the current process with …

  9. How to Restart Python Script after Exception and Run it Forever

    Jan 30, 2019 · Restart a Python script after an exception and run it forever. This guide shows you how to ensure your script stays active!

  10. python - Restarting a program after exception - Stack Overflow

    To restart anything, just use a while loop outside the try. For example: while True: try: foo2() except: pass. else: break. And if you want to pass the exception up the chain, just do this in …

  11. Some results have been removed
Refresh