Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
On Thu, 2011-02-03 at 17:57 -0600, Thomas L. Shinnick wrote: > At 05:33 PM 2/3/2011, Westley Martínez wrote: > > > On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: > > > > > On Thu, 03 Feb 2011 > > > 07:58:55 -0800, Ethan Furman wrote: > > > > Steven D'Aprano wrote: > > > [snip] > > >

Re: os.path.join doubt

2011-02-03 Thread Thomas L. Shinnick
At 05:33 PM 2/3/2011, Westley Martínez wrote: On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: [snip] Yes. Is there a problem? All those paths should be usable from Windows. If you find it ugly to see path

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
On Thu, 2011-02-03 at 23:11 +, Steven D'Aprano wrote: > On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > > > Steven D'Aprano wrote: > >> BTW, Windows accepts / as well as \ as a path separator. You will have > >> far fewer headaches if you use that. > > > > Just because Windows acce

Re: os.path.join doubt

2011-02-03 Thread Steven D'Aprano
On Thu, 03 Feb 2011 07:58:55 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: >> BTW, Windows accepts / as well as \ as a path separator. You will have >> far fewer headaches if you use that. > > Just because Windows accepts / doesn't make it a good idea... No. Windows accepting slashes as th

Re: os.path.join doubt

2011-02-03 Thread Ethan Furman
Steven D'Aprano wrote: BTW, Windows accepts / as well as \ as a path separator. You will have far fewer headaches if you use that. Just because Windows accepts / doesn't make it a good idea... Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help",

Re: os.path.join doubt

2011-02-03 Thread Westley Martínez
'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 win

Re: os.path.join doubt

2011-02-03 Thread Nobody
On Thu, 03 Feb 2011 06:31:49 +, Steven D'Aprano wrote: > On Wed, 02 Feb 2011 20:46:12 -0800, harryos wrote: > >> In windows ,I tried this >> >> p1 = "C:\Users\me\Documents" >> p2 = "..\Pictures\images\my.jpg" Don't do this; backslash is significant within Python string literals. If want to

Re: os.path.join doubt

2011-02-02 Thread Steven D'Aprano
On Wed, 02 Feb 2011 20:46:12 -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\\Pi

Re: os.path.join doubt

2011-02-02 Thread Chris Rebert
On Wed, Feb 2, 2011 at 8:46 PM, 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\