Add abspath()

This commit is contained in:
Guido van Rossum 1999-01-29 18:05:18 +00:00
parent 1804dc3c07
commit e294cf620a
4 changed files with 28 additions and 0 deletions

View File

@ -332,3 +332,10 @@ def normpath(path):
comps.append('.')
return prefix + string.joinfields(comps, os.sep)
# Return an absolute path.
def abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)

View File

@ -212,3 +212,10 @@ def walk(top, func, arg):
name = join(top, name)
if isdir(name):
walk(name, func, arg)
# Return an absolute path.
def abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)

View File

@ -365,3 +365,10 @@ def normpath(path):
if not prefix and not comps:
comps.append('.')
return prefix + string.joinfields(comps, os.sep)
# Return an absolute path.
def abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)

View File

@ -367,3 +367,10 @@ def normpath(path):
if not comps and not slashes:
comps.append('.')
return slashes + string.joinfields(comps, '/')
# Return an absolute path.
def abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)