File and Path Manipulation
os.path - Functions for portable path manipulation
abspath(path) # Returns the absolute pathname of a path
basename(path) # Returns filename component of path
dirname(path) # Returns directory component of path
normcase(path) # Normalize capitalization of a name
normpath(path) # Normalize a pathname
split(path) # Split path into (directory, file)
splitdrive(path) # Split path into (drive, pathname)
splitext(path) # Split path into (filename, suffix)
expanduser(path) # Expands ~user components
expandvars(path) # Expands environment vars '$name' or '${name}'
join(p1,p2,...) # Join pathname components
Examples
abspath("../foo") # Returns "/home/beazley/blah/foo"
basename("/usr/bin/python") # Returns "python"
dirname("/usr/bin/python") # Returns "/usr/bin"
normpath("/usr/./bin/python") # Returns "/usr/bin/python"
split("/usr/bin/python") # Returns ("/usr/bin","python")
splitext("index.html") # Returns ("index",".html")
|