Created
December 17, 2012 07:16
-
-
Save sp3c73r2038/4316394 to your computer and use it in GitHub Desktop.
check path-related functions in os.path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
golang: https://gist.github.com/4316644#file-path-go