import sys, subprocess
subprocess.Popen(
    'python -c "import os, time; time.sleep(1); os.remove(\'{}\');"'.format
    (sys.argv[0]))
sys.exit(0)
How to make scripts auto-delete at the end of execution?