need help
JacobMcPherson1 (239)

How do you make the files (except main.py) delete themselves after the program is stopped

You are viewing a single comment. View All
19ecal (233)

Well, you can tell users to send KeyboardInterrupt (Ctrl+C) when they are done and then use something like this

import os
try:
    #your main code here
    files=["test.py", "file.txt"]
except KeyboardInterrupt:
    for file in files:
        os.remove(file)

does that help?

JacobMcPherson1 (239)

@19ecal well chicken said that if someone other than the repl owner runs the repl, it'll delete the files. But thanks anyway