Skip to content

Instantly share code, notes, and snippets.

@MorganRamsay
Last active February 2, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MorganRamsay/fcef50ce3059b310449302575989d3e8 to your computer and use it in GitHub Desktop.
Save MorganRamsay/fcef50ce3059b310449302575989d3e8 to your computer and use it in GitHub Desktop.
Python 3.6.4: os.path.abspath (lines 537-554 in ntpath.py)
else: # use native Windows method on Windows
def abspath(path):
"""Return the absolute version of a path."""
if path: # Empty path must return current working directory.
path = os.fspath(path)
try:
path = _getfinalpathname(path).replace('\\\\?\\', '')
except OSError:
pass # Bad path - return unchanged.
elif isinstance(path, bytes):
path = os.getcwdb()
else:
path = os.getcwd()
return normpath(path)
# realpath is a no-op on systems without islink support
realpath = abspath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment