3 ms·
I don't think __file__ would be any different... it's not even an absolute path necessarily. That's why I said I don't think there's any secure way to do this i
by mehrdadn 7y ago
I don't think __file__ would be any different... it's not even an absolute path necessarily. That's why I said I don't think there's any secure way to do this in Python.
You're right though, I didn't see the issue was still there. The home directory should also not be there either. I think I looked at this too hastily but now I'm confused too.
- user5994461 7y agoos.path.realpath(__file__) That will give you the absolute path of the current python script, dereferencing any symlink and the .. notation.
- mehrdadn 7y agoIt will also be insecure due to a race condition.