Title: Theory / Unimportant / CS / Programming / Python / Lib / 16.1 os.path
Tags: FromInstruction computer_to_instruction automatedNewLineAfterCommaSpace FromVariables hasNotNewEffectReturnsMeaning
On every note of this deck, unless a note says otherwise:
Page: https://docs.python.org/3/library/os.path.html#module-os.path
Language: Python
Context: os.path

Variable: os.path
Meaning: module implements some useful functions on pathnames.
Page: https://docs.python.org/3/library/os.path.html#module-os.path
Language: Python

Instruction: abspath(path)
Effect: a normalized absolutized version of the pathname path

Instruction: basename(path)
Effect: the base name of pathname path.

Name: basename of p
Definition: last pathname component, after the last slash
Page: https://docs.python.org/3/library/os.path.html#module-os.path
Variables: p a path
Context: os.path

Instruction: commonpath(paths)
Returns: the longest common sub-path of each pathname in the sequence paths
Assuming: non-empty. All absolute or all relative
Typ: valid path

Instruction: os.path.commonprefix(list)
Returns: The longest path prefix (taken character-by-character) that is a prefix of all paths in list. If list is empty, return the empty string ('').
Typ: potentially invalid path

Instruction: dirname(path)
Returns: the directory name of pathname path

Instruction: exists(path)
Returns: Whether it refers to an existing path or open file descriptor and not broken symbolic link. May return false if stat() can't be executed while the path exists

Instruction: lexists(path)
Returns: Whether it refers to an existing path or open file descriptor even for a broken symbolic link. May return false if stat() can't be executed while the path exists

Instruction: expanduser(path)
Returns: Replace ~ by the absolute user directory

Instruction: expandvars(path)
Returns: path, with argument variables expnaded

Instruction: getatime(path)
Returns: time of last access of path
Typ: float, number of seconds since epoch

Instruction: getmtime(path)
Returns: time of last modification of path
Typ: float, number of seconds since epoch

Instruction: getctime(path)
Returns: time of last metadata change of path
Typ: float, number of seconds since epoch

Instruction: getsize(path)
Returns: the size, in bytes, of path.
Assuming: file exists and is accessible

Instruction: isabs(path)
Returns: whether path is an absolute path name

Instruction: isfile(path)
Returns: whether path is an existing regular file, following symbolinc link

Instruction: isdir(path)
Returns: whether path is an existing directory, following symbolinc link

Instruction: islink(path)
Returns: whether path is an existing director that is a symbolic link, and python support symbolic link

Instruction: ismount(path)
Returns: whether path is a mount point

Instruction: os.path.join(
  path,
  *paths
)
Returns: the concatenation of all arguments, with a directory separator between all of them.
Discard everything before the last absolute path

Instruction: normcase(path)
Returns: path with case normalized. I.e. unchanged if case sensitive, lower case otherwise

Instruction: normpath(path)
Returns: path with redundant separator removed.

Instruction: realpath(path)
Returns: canonical version of path

Instruction: relpath(
  path,
  start
)
Returns: path as a relative path starting from directory start

Instruction: relpath(path)
Returns: path as a relative path starting from current directory

Instruction: samefile(path1,path2)
Returns: Whether both path refer to the same file

Instruction: sameopenfile(descriptor1,descriptor2)
Returns: Whether both descriptors refer to the same file

Instruction: samestat(stat1,stat2)
Returns: Whether both stats refer to the same file

Instruction: split(path)
Returns: the pair with dirname and basename.

Instruction: splitdrive(path)
Returns: a pair with mount point and the part of the path after it.

Instruction: splitext(path)
Returns: a pair with the extension (including its dot) as second element, and everything else as first element

Instruction: supports_unicode_filenames
Returns: Whether arbitrary Unicode strings can be used as file names (within limitations imposed by the file system).