Created
January 12, 2014 15:28
-
-
Save aelaguiz/8386014 to your computer and use it in GitHub Desktop.
weird behavior of relpath
This file contains hidden or 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
Python: | |
os.chdir(path) | |
cwd = os.getcwd() | |
print path | |
print cwd | |
print os.path.relpath(path, start=cwd) | |
output: | |
./themes/bold | |
/Users/aelaguiz/workspace/cratejoy/themes/bold | |
themes/bold | |
From command line: | |
(venv)amir-laptop:cratejoy aelaguiz$ python | |
Python 2.7.5 (default, Aug 25 2013, 00:04:04) | |
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import os.path | |
>>> os.path.relpath("./themes/bold", "/Users/aelaguiz/workspace/cratejoy/themes/bold") | |
'.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the fact it says it doesn't use the FS is kind of a lie, it's at least aware of cwd, so I think your os.chdir is confusing things.