Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
Created December 17, 2012 07:16
Show Gist options
  • Save sp3c73r2038/4316394 to your computer and use it in GitHub Desktop.
Save sp3c73r2038/4316394 to your computer and use it in GitHub Desktop.
check path-related functions in os.path
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# put this script in the path like
# assumed /tmp (cwd)
# /tmp/dir1/dir2/path.py
# /tmp/dir3 symlinked to /tmp/dir1/dir2
#
# and run with
# python ../tmp/hello3/path.py
from os import getcwd
from os.path import normpath, abspath, realpath, join
import sys
p = sys.argv[0]
print "origin: %s" % p
print "normpath: %s" % normpath(p)
print "abspath: %s" % abspath(p)
print "realpath: %s" % realpath(p)
print "normpath(join(getcwd(), p): %s" % normpath(join(getcwd(), p))
@erning
Copy link

erning commented Dec 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment