Last active
February 21, 2016 20:30
-
-
Save maphew/9368fe16df751b016bbd to your computer and use it in GitHub Desktop.
python 2.7.8 broken raw string?
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
import os | |
import sys | |
wspace = r'D:\Feb-19' | |
tile = '116o' | |
ex1 = os.path.join(wspace, r'Work_{}\scratch.gdb'.format(tile)) | |
ex2 = os.path.join(wspace, r'\Work_{}\scratch.gdb'.format(tile)) | |
print(sys.version) | |
print('''\n--- Expected --- | |
no-slash-W D:\Feb-19Work_116o\scratch.gdb | |
yes-slash-W D:\Feb-19\Work_116o\scratch.gdb | |
''') | |
print('''--- Actual Result --- | |
no-slash-W {} | |
yes-slash-W {} | |
'''.format(ex1, ex2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Raw is doing the right thing, what's happening is that
os.path.join
disregards everything preceding the argument with a leading slash (arg is treated as root element). See http://stackoverflow.com/questions/35516674/python-raw-string-literal-with-slash-w-r-w/35517343#35517343