ntpath bug or expected?
dsavitsk at e-coli.net
Thu Sep 12 03:18:21 CEST 2002
python 2.1.3. this is pretty minor ... os.path.join() on win32 fails if the
first path component is C: (or any other letter). that is, if the first
component is a drive letter, it must contain either '\\' or '/' or else the
path is wrong. this makes it the only component which must have slashes.
>>> os.path.join('C:', 'path', 'to', 'file.txt')
the offending code is below and can be easily fixed by removing the ':' from
def join(a, *p):
"""Join two or more pathname components, inserting "\\" as needed"""
path = a
for b in p:
path = b
elif path == '' or path[-1:] in '/\\:':
path = path + b
path = path + "\\" + b
More information about the Python-list