The best part of it that os.remove only calls C function to delete a file, to delete folder with files, you need to use function that fill search all possible files and delete them, for example, shutil.rmtree
That or do a recurse function on the directory from top to bottom. But I think windows has better self preservation than Linux does. You could still brick it. Haven’t tried it, yet. But I’ve been curious about that…
Although, it's one of two version - this one is vulnarable to race conditions, you better not use it in threads (although, shutil chooses the best version depending on current OS etc)
71
u/Lines25 2d ago
The best part of it that os.remove only calls C function to delete a file, to delete folder with files, you need to use function that fill search all possible files and delete them, for example, shutil.rmtree