Re: more on unescaping escapes

2009-02-24 Thread bvdp
Adam Olsen wrote: On Feb 23, 7:18 pm, bvdp wrote: Gabriel Genellina wrote: En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python

Re: more on unescaping escapes

2009-02-24 Thread Adam Olsen
On Feb 23, 7:18 pm, bvdp wrote: > Gabriel Genellina wrote: > > En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: > >> Gabriel Genellina wrote: > >>> En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: > Chris Rebert wrote: > > On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: > > > [pro

Re: more on unescaping escapes

2009-02-24 Thread Rhodri James
On Tue, 24 Feb 2009 00:46:34 -, bvdp wrote: Just because I never really thought too much about it :) I'm doing my work on a linux box and my user is on windows ... and he's used to using '\' ... but, you are absolutely right! Just use '/' on both systems and be done with it. Of course

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Gabriel Genellina wrote: En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there an

Re: more on unescaping escapes

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you ca

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the

Re: more on unescaping escapes

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windo

Re: more on unescaping escapes

2009-02-23 Thread Mel
bvdp wrote: > Not sure if it's more clear or not :) > > >>> a="c:\\Program\x20Files\\test" > >>> a > 'c:\\Program Files\\test' > >>> print a > c:\Program Files\test > > Which is all fine. And I didn't need to use decode(). > > So, in this case I'm assuming that the interpreter is converting t

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Bear in mind that it's the string as it really is that is being operated on, not the representation of it that you displayed Yes, that is the confusion ... what is displayed and what's actually in the string. I think I understand it all now :) Thanks. -- http://mail.python.org/mailman/lis

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windows from Python in nearly all cases and you can easily

Re: more on unescaping escapes

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windows from Python in nearly all cases and you can easily interconvert using os.

Re: more on unescaping escapes

2009-02-23 Thread Rhodri James
On Tue, 24 Feb 2009 00:26:29 -, bvdp wrote: So, in this case I'm assuming that the interpreter is converting the escapes on assignment. The compiler converts the escapes on creating its internal representation of the string, before assignment ever gets involved. -- Rhodri James *-* Wild

Re: more on unescaping escapes

2009-02-23 Thread Rhodri James
On Mon, 23 Feb 2009 22:05:42 -, bvdp wrote: So, we think something is working and send of a bug fix to our client :) I'm not sure I understand this at all and wonder if there is bug? >>> a="c:\\Program\x20Files\\test" >>> a 'c:\\Program Files\\test' so far, so good. >>> a.decode("st

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Tim Wintle wrote: On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote: Let's see if this makes sense: >>> a='c:\\Program Files\\test' >>> a.decode('string-escape') 'c:\\Program Files\test' Hint: try running print a and see what's written - I think that the interpreter adds extra "\" character

Re: more on unescaping escapes

2009-02-23 Thread bvdp
andrew cooke wrote: do you know that a string with the letter "r" in front doesn't escape slashes? it's intended for regular expressions, but would simplify things for you here too. just do a=r'c:\\Program Files\test' Yes, I knew that. Unfortunately in my program loop I really don't have

Re: more on unescaping escapes

2009-02-23 Thread Tim Wintle
On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote: > Let's see if this makes sense: > > >>> a='c:\\Program Files\\test' > >>> a.decode('string-escape') > 'c:\\Program Files\test' Hint: try running >>> print a and see what's written - I think that the interpreter adds extra "\" characters to escap

Re: more on unescaping escapes

2009-02-23 Thread andrew cooke
do you know that a string with the letter "r" in front doesn't escape slashes? it's intended for regular expressions, but would simplify things for you here too. just do a=r'c:\\Program Files\test' andrew bvdp wrote: > > I'm getting hopelessly lost in a series of \\\ s :) > > Let's see

Re: more on unescaping escapes

2009-02-23 Thread bvdp
I'm getting hopelessly lost in a series of \\\ s :) Let's see if this makes sense: >>> a='c:\\Program Files\\test' >>> a.decode('string-escape') 'c:\\Program Files\test' In this case there are still 2 '\'s before the P; but only 1 before the 't'. Now, when it comes time to open the file w

Re: more on unescaping escapes

2009-02-23 Thread MRAB
bvdp wrote: So, we think something is working and send of a bug fix to our client :) I'm not sure I understand this at all and wonder if there is bug? >>> a="c:\\Program\x20Files\\test" >>> a 'c:\\Program Files\\test' so far, so good. >>> a.decode("string-escape") 'c:\\Program Files\test'

more on unescaping escapes

2009-02-23 Thread bvdp
So, we think something is working and send of a bug fix to our client :) I'm not sure I understand this at all and wonder if there is bug? >>> a="c:\\Program\x20Files\\test" >>> a 'c:\\Program Files\\test' so far, so good. >>> a.decode("string-escape") 'c:\\Program Files\test' Umm, not so go