Python securely remove file

kyle k picture kyle k · Jul 3, 2013 · Viewed 7.3k times · Source

How can I securely remove a file using python? The function os.remove(path) only removes the directory entry, but I want to securely remove the file, similar to the apple feature called "Secure Empty Trash" that randomly overwrites the file.

What function securely removes a file using this method?

Answer

jh314 picture jh314 · Jul 3, 2013

You can use srm to securely remove files. You can use Python's os.system() function to call srm.