Inspired from https://blog.petrzemek.net/2014/03/23/restarting-a-python-script-within-itself/
def restart():
import sys
print("argv was",sys.argv)
print("sys.executable was", sys.executable)
print("restart now")
import os
os.execv(sys.executable, ['python'] + sys.argv)
works for python 3?