[Python-ideas] Support os.path.join for Windows paths on Posix

Bruce Leban bruce at leapyear.org
Wed Oct 30 23:56:44 CET 2013


ntpath still gets drive-relative paths wrong on Windows:

>>> ntpath.join(r'\\a\b\c\d', r'\e\f')
'\\e\\f'
# should be r'\\a\b\e\f'

>>> ntpath.join(r'C:\a\b\c\d', r'\e\f')
'\\e\\f'
# should be r'C:\e\f'

(same behavior in Python 2.7 and 3.3)

--- Bruce
I'm hiring: http://www.cadencemd.com/info/jobs
Latest blog post: Alice's Puzzle Page http://www.vroospeak.com
Learn how hackers think: http://j.mp/gruyere-security


On Wed, Oct 30, 2013 at 3:43 PM, אלעזר <elazarg at gmail.com> wrote:

> 2013/10/31 Ryan Gonzalez <rymg19 at gmail.com>:
> >>>> import os
> >>>> os.path.join('C:\\', 'x.jpg')
> > 'C:\\/x.jpg'
> >>>>
> >
> > Isn't something wrong there? My idea: check for \'s in the path. If there
> > are any, assume \ is the path separator, not /.
>
> No, nothing is wrong:
>
> C:\Dev>cd C:\/temp
>
> C:\Temp>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131030/0b82c782/attachment.html>


More information about the Python-ideas mailing list