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)
@Techtiger255 Because that's not how you concatenate lists in python:
Alternatively, you could do
my_list.extend(['spam'])
, however this modifiesmy_list
and might not be what you want.