os.path.join doubt
Westley Martínez
anikom15 at gmail.com
Thu Feb 3 09:24:44 EST 2011
'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg' is a valid
path. .. means parent, not 'go back a directory'. But you should really
be trying this:
p1 = os.environ['HOMEPATH']
p2 = os.path.join(p1, 'Pictures', 'images', 'my.jpg')
On Wed, 2011-02-02 at 20:46 -0800, harryos wrote:
> In windows ,I tried this
>
> p1 = "C:\Users\me\Documents"
> p2 = "..\Pictures\images\my.jpg"
>
> print os.path.join(p1,p2)
> This gives
> 'C:\\Users\\me\\Documents\\..\\Pictures\\images\\my.jpg'
>
> I expected I would get
> 'C:\\Users\\me\\Pictures\\images\\my.jpg'
>
> I thought os.path.join would join the paths more intelligently..Any
> idea why this happens ?
> harry
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110203/10d81d26/attachment-0001.html>
More information about the Python-list
mailing list