Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save plieningerweb/39e47584337a516f56da105365a2e4c6 to your computer and use it in GitHub Desktop.
Save plieningerweb/39e47584337a516f56da105365a2e4c6 to your computer and use it in GitHub Desktop.
Restart python script itsself (run again).md
@dante-nl
Copy link

dante-nl commented Feb 8, 2021

Amazing, thank you!

@dante-nl
Copy link

dante-nl commented Feb 8, 2021

Seems like the input function is broken with it tho...

@YYx00xZZ
Copy link

if you want to run/restart your script with -i its not working

@heyjoeway
Copy link

Wouldn't it make more sense to not hardcode the executable name?

import os, sys
def restart():
    os.execv(sys.executable, [os.path.basename(sys.executable)] + sys.argv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment