os.remove(path) is equal to os.unlink(path), so how can I delete the file if it just becomes unlinked?
Also I haven't tried to yet, but does './file.txt' work as is or do I must provide the full path?
Or do I just need to use the 'file.txt' if it the same folder? Or they both work the same like os.remove(path) and os.unlink(path)?
And if './file.txt' works then what about '../file.txt'?
If there's no file system entry for a file, it does not consume space. Zeroing the bytes of a file will not make it consume less space, but it will make it harder to recover the file after you delete it. However writing the empty string to a file before deleting it will not zero the bytes. It will do basically nothing (it's pretty much the same as deleting the original file, creating a new empty one and then deleting that as well).
If all you want is to free disk space, just delete the file with unlink/remove.
But open(path, "w")? The "w" overwrites the file, so open(path, "w") all by itself has removed the file and placed a new one in its place with under the exact same name?
I guess I should have thought of an overwrite as a write over.
Fine then how can I zero the bytes and bits out?
And what about open(path, "r+").write("something") and open(path, "a").write("something") won't that change the bits and bytes? Or does it just unlink the file and write a new one it its place?
Python only wraps the lower level system functions which open a file to create a file descriptor or a pointer to file, and the corresponding read or write functions. So, for example you could ask in the C forum if fopen() with mode 'w' physically overwrites existing contents on the drive, or if it may write in a different place.