[issue29831] os.path.exists seems can not recgnize "~"

Josh Rosenberg report at bugs.python.org
Thu Mar 16 21:51:59 EDT 2017


Josh Rosenberg added the comment:

That's because os.system is executing the command in a shell (which expands ~). Without shell support, ~ doesn't mean anything unless used with the APIs that specifically support it (e.g. os.path.expanduser).

You wanted os.path.exists(os.path.expanduser('~/.zshrc'))

This is not a bug.

----------
nosy: +josh.r

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29831>
_______________________________________


More information about the Python-bugs-list mailing list