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

Guido van Rossum guido at python.org
Wed Oct 30 23:50:39 CET 2013


No, nothing's wrong. You should use the ntpath module in this case.

You should also be using Python 3. :-)

$ python3
Python 3.4.0a4+ (default:0917f6c62c62, Oct 22 2013, 10:55:35)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ntpath
>>> ntpath.join('C:\\', 'x.jpg')
'C:\\x.jpg'
>>>



On Wed, Oct 30, 2013 at 3:35 PM, Ryan Gonzalez <rymg19 at gmail.com> wrote:

> The recent thread/post/whatever on os.path.join has gotten me thinking.
> Say I wanted to join a Windows path...on Ubuntu. This is what I get:
>
> ryan at DevPC-LX:~$ python
> Python 2.7.3 (default, Sep 26 2013, 20:03:06)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 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 /.
>
> --
> Ryan
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131030/aff21b13/attachment.html>


More information about the Python-ideas mailing list