5 ms·
That only works if you know the resource in advance. Doesn't work if for example you're trying to delete files matching a glob and you have to enumerate them by
by IshKebab 2y ago
That only works if you know the resource in advance. Doesn't work if for example you're trying to delete files matching a glob and you have to enumerate them by name and then delete them by name.
The filesystem API offers a solution for that. The process API doesn't (maybe with procfd; I haven't tried that API yet since it's so new).
- ijustlovemath 2y agoI'm not sure that counts as TOCTOU? What I'm saying is that instead of writing code like: for fname in someglob: if os.path.exists(fname): os.unlink(fname) You should instead write for fname in someglob: os.unlink(fname) and handle the errors.