posixpath
This module implements some useful functions on POSIX pathnames.
Do not import this module directly. Instead, import the
module os
and use os.path
.
posixpath.split(p)
.
''
).
$HOME
;
an initial `~user' is looked up in the password directory through
the built-in module pwd
. If the expansion fails, or if the
path does not begin with a tilde, the path is returned unchanged.
islink()
and isfile()
can be
true for the same path.
islink()
and isdir()
can be true
for the same path.
p/..
', is on a
different device than p, or whether `p/..
' and
p point to the same i-node on the same device -- this should
detect mount points for all Unix and POSIX variants.
'/'
) inserted
between components, unless p is empty.
macpath
converts upper case to
lower case.
stat()
call on either pathname fails.
(head, tail)
,
where tail is the last pathname component and head is
everything leading up to that. The tail part will never contain
a slash; if p ends in a slash, tail will be empty. If
there is no slash in p, head will be empty. If p is
empty, both head and tail are empty. Trailing slashes are
stripped from head unless it is the root (one or more slashes
only). In nearly all cases, join(head, tail)
equals p (the only exception being when there were multiple
slashes separating head from tail).
(root, ext)
such that root + ext == p
,
and ext is empty or begins with a period and contains
at most one period.
(arg, dirname, names)
for each directory in the
directory tree rooted at p (including p itself, if it is a
directory). The argument dirname specifies the visited directory,
the argument names lists the files in the directory (gotten from
posix.listdir(dirname)
).
The visit function may modify names to
influence the set of directories visited below dirname, e.g., to
avoid visiting certain parts of the tree. (The object referred to by
names must be modified in place, using del
or slice
assignment.)