Description
The os.path
docs intro includes:
Note: Since different operating systems have different path name conventions, there are several versions of this module in the standard library. The
os.path
module is always the path module suitable for the operating system Python is running on, and therefore usable for local paths. However, you can also import and use the individual modules if you want to manipulate a path that is always in one of the different formats. They all have the same interface:
posixpath
for UNIX-style pathsntpath
for Windows paths
But we don't explain that some of the functions in ntpath
and posixpath
aren't suitable for usage on a "foreign" OS, e.g. that using ntpath.realpath()
from POSIX is a bad idea.
These functions are safe because they do purely lexical work:
basename
commonpath
commonprefix
dirname
isabs
join
normcase
normpath
split
splitdrive
splitroot
splitext
These functions are probably unsafe because they rely on details of the host OS (e.g. via the os
module):
abspath
exists
lexists
expanduser
expandvars
getatime
getmtime
getctime
getsize
isfile
isdir
isjunction
islink
ismount
isdevdrive
realpath
relpath
samefile
sameopenfile
samestat
supports_unicode_filenames