os.path.dirname()

os.path.dirname(p)[source]

Returns the directory component of a pathname