0

I am storing files inside a pickle file for later use but how do I delete the pickle file after I close the program? Anyone can help, please? I have in mind using os.remove but where I put it in the code only if after closing a python program the os.remove will be used?

Diego
  • 9
  • 2
  • Yeah, I have seen os.remove and stuff but where do I put it if I want to use it only if I want to close the python program? – Diego Feb 23 '19 at 03:06
  • 1
    How is your program like? How does it work? Be a little more specific. – Rafael Barros Feb 23 '19 at 03:07
  • I just need to know how to activate the os.remove after I close the python program – Diego Feb 23 '19 at 03:17
  • Check this: https://stackoverflow.com/questions/3850261/doing-something-before-program-exit – Rafael Barros Feb 23 '19 at 03:19
  • "Ideally", a simple program would have a natural 'return'-termination. In conjunction with (hah!) [with](http://effbot.org/zone/python-with-statement.htm), this makes it relatively easy to deal with resources. Processes that are terminated abruptly (ie. "clicking the X" on a terminal's window frame) generally have little guarantee of cleanup.. YMMV with the exact OS and mechanism. – user2864740 Feb 23 '19 at 04:26
  • Oh I see, thank you. – Diego Feb 23 '19 at 05:03

0 Answers0