Python Os Path

os.path is a module providing filesystem APIs.


Functions

Function

Example

abspath()

see Path.absolute

basename()

see Path.name

commonpath()

commonpath('/usr/lib', '/usr/local') returns '/usr'

commonprefix()

commonprefix('/usr/lib', '/usr/local') returns '/usr/l'

dirname()

see Path.parent

exists()

see Path.exists

expanduser()

see Path.expanduser and Path.home

expandvars()

variable references like $name and ${name} (and %name% on Windows) are replaced with variable values if defined

getatime()

last access time of a file, as a float representing seconds since the epoch

getctime()

last metadata change time (Unix) or creation time (Windows) of a file

getmtime()

last modification time of a file

getsize()

size of a file

isabs()

see Path.is_absolute

isdir()

see Path.is_dir

isfile()

see Path.is_file

islink()

see Path.is_symlink

join()

see Path.joinpath

normcase()

on Windows only, push letters to lowercase and replace forward slashes (/) with backslashes (\)

normpath()

collapse redundant separators and up-level references

realpath()

see Path.resolve

relpath()

see Path.relative_to

samefile()

see Path.samefile

sameopenfile()

test if two open file objects are the same

samestat()

test if two os.stat_result instances are the same

split()

split('/usr/bin') returns ('/usr/', 'bin', ); split('/usr/') returns ('/usr/', '', )

splitdrive()

on Windows only, split the drive letter or UNC host name off

splitext()

see Path.stem and Path.suffix


See also

Python os.path module documentation

Python Module of the Day article for os.path


CategoryRicottone

Python/Os/Path (last edited 2023-10-11 19:43:17 by DominicRicottone)