Re: [Tutor] Raw string form variable

2013-05-05 Thread Steven D'Aprano
On 05/05/13 18:00, Ajin Abraham wrote: Please refer this paste: http://bpaste.net/show/vsTXLEjwTLrWjjnfmmKn/ and suggest me the possible solutions. There is no need for a paste bin for this. In six months time, when other people are searching the mail archives looking for answers, the paste bi

Re: [Tutor] Raw string form variable

2013-05-05 Thread Peter Otten
Ajin Abraham wrote: > Please refer this paste: http://bpaste.net/show/vsTXLEjwTLrWjjnfmmKn/ > and suggest me the possible solutions. > Regards, Quoting the paste: > i am executing these in Python 2.7 interpreter > >>>import os > >>> os.path.join(r'C:\win\apple.exe') > #will returns me = 'C:\\win

[Tutor] Raw string form variable

2013-05-05 Thread Ajin Abraham
Please refer this paste: http://bpaste.net/show/vsTXLEjwTLrWjjnfmmKn/ and suggest me the possible solutions. Regards, Ajin Abraham ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listin

Re: [Tutor] Raw string

2010-04-18 Thread Steve Willoughby
On Sun, Apr 18, 2010 at 06:48:47PM -0400, bob gailer wrote: > On 4/18/2010 5:49 PM, Neven Gor??i?? wrote: > >When I get file path from DirDialog, I get in a (path) variable. > >Sometimes that string (path) contains special escape sequences, such > >as \x, \r and so on. Since this is a tutorial li

Re: [Tutor] Raw string

2010-04-18 Thread Steven D'Aprano
On Mon, 19 Apr 2010 07:49:31 am Neven Goršić wrote: > Hi! > > When I get file path from DirDialog, I get in a (path) variable. > Sometimes that string (path) contains special escape sequences, such > as \x, \r and so on. > > 'C:\Python25\Programs\rating' That creates a string containi

Re: [Tutor] Raw string

2010-04-18 Thread bob gailer
On 4/18/2010 5:49 PM, Neven Goršić wrote: Hi! When I get file path from DirDialog, I get in a (path) variable. Sometimes that string (path) contains special escape sequences, such as \x, \r and so on. 'C:\Python25\Programs\rating' When I try to open that file (whose name contain

Re: [Tutor] Raw string

2010-04-18 Thread Alan Gauld
"Neven Gorsic" wrote When I get file path from DirDialog, I get in a (path) variable. Sometimes that string (path) contains special escape sequences, such as \x, \r and so on. 'C:\Python25\Programs\rating' When I try to open that file (whose name contains escape sequences) it do

[Tutor] Raw string

2010-04-18 Thread Neven Goršić
Hi! When I get file path from DirDialog, I get in a (path) variable. Sometimes that string (path) contains special escape sequences, such as \x, \r and so on. 'C:\Python25\Programs\rating' When I try to open that file (whose name contains escape sequences) it doesn't work. I know t

Re: [Tutor] Raw string

2008-07-21 Thread Mark Tolonen
"Neven Gorsic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Mon, Jul 21, 2008 at 9:44 AM, Monika Jisswel <[EMAIL PROTECTED]> wrote: instead of s='e:\mm tests\1. exp files\5.MOC-1012.exp' try to use : s = r'e:\mm tests\1. exp files\5.MOC-1012.exp'.replace( '\\', '') for m

Re: [Tutor] Raw string

2008-07-21 Thread Lie Ryan
> Thanks, > I am aware of goodies that raw string offers, but my question was > how to use it with variable that already contains string. :) If you really have to, you may use something like this: # Untested def kludge(s): s = 'r"""%s"""' % repr(s) return eval(s) Most people would fr

Re: [Tutor] Raw string

2008-07-21 Thread Neven Goršić
2008/7/21 Martin Walsh <[EMAIL PROTECTED]>: > Neven Goršić wrote: >> I read from one file plenty of parameters and among them one file name >> of other file. >> That file name is 'e:\mm tests\1. exp files\5.MOC-1012.exp' and I hold >> it in variable s. > > As John pointed out, if you're really read

Re: [Tutor] Raw string

2008-07-21 Thread Monika Jisswel
> > I don't know in advance what the file name will be... import re for line in myfile: if re.search(r'\', line): line = line.replace('\\', '') if you have lines that contain a \ in them that you don't want to substitute then you need another if statement. ___

Re: [Tutor] Raw string

2008-07-21 Thread Martin Walsh
Neven Goršić wrote: > I read from one file plenty of parameters and among them one file name > of other file. > That file name is 'e:\mm tests\1. exp files\5.MOC-1012.exp' and I hold > it in variable s. As John pointed out, if you're really reading this string from a file (with something like file

Re: [Tutor] Raw string

2008-07-21 Thread Monika Jisswel
> > Thanks, > I am aware of goodies that raw string offers, but my question was how to > use it with variable that already contains string. :) > if you are reading the value from a file : import re for line in myfile: if re.search(r'e:\mm tests\1. exp files\5.MOC-1012.exp', line): l

Re: [Tutor] Raw string

2008-07-21 Thread Neven Goršić
On Mon, Jul 21, 2008 at 9:44 AM, Monika Jisswel <[EMAIL PROTECTED]> wrote: > instead of s='e:\mm tests\1. exp files\5.MOC-1012.exp' > try to use : s = r'e:\mm tests\1. exp files\5.MOC-1012.exp'.replace( > '\\', '') > for me here is what it gives: > s = r'e:\mm tests\1. exp files\5.MOC-101

Re: [Tutor] Raw string

2008-07-21 Thread Monika Jisswel
instead of s='e:\mm tests\1. exp files\5.MOC-1012.exp' try to use : s = r'e:\mm tests\1. exp files\5.MOC-1012.exp'.replace('\\', '') for me here is what it gives: >>> s = r'e:\mm tests\1. exp files\5.MOC-1012.exp'.replace('\\', '') >>> print s e:\\mm tests\\1. exp files\\5.MOC-1012.exp >>

Re: [Tutor] Raw string

2008-07-20 Thread John Fouhy
On 21/07/2008, Neven Goršić <[EMAIL PROTECTED]> wrote: > >>> s='e:\mm tests\1. exp files\5.MOC-1012.exp' > >>> os.path.split(s) > ('e:\\', 'mm tests\x01. exp files\x05.MOC-1012.exp') [...] > The problem is that \1 and \5 is wrongly understood. Yup, that's not surprising. > I know that > ever

Re: [Tutor] Raw string

2008-07-20 Thread Neven Goršić
On Sun, Jul 20, 2008 at 5:48 PM, Steve Willoughby <[EMAIL PROTECTED]> wrote: > Neven Goršić wrote: >> >> Hi! >> >> In every manual and book I read only one way to make a raw string: >> r"e:\mm tests\1. exp files\5.MOC-1012.exp". >> I don't know how to make a string raw string if it is already >> co

Re: [Tutor] Raw string

2008-07-20 Thread bob gailer
Neven Goršić wrote: Hi! In every manual and book I read only one way to make a raw string: r"e:\mm tests\1. exp files\5.MOC-1012.exp". I don't know how to make a string raw string if it is already contained in a variable. s.raw() or something like that ... Looking up raw string in the docs

Re: [Tutor] Raw string

2008-07-20 Thread Steve Willoughby
bob gailer wrote: I'm guessing you want >>> x.raw() # to display r"\t" Is that true. That's the only way I can interpret your question. Hm... or did you (speaking to the OP) intend for your script to interpret strings you're reading from another source, like user input or a text file, and

Re: [Tutor] Raw string

2008-07-20 Thread Steve Willoughby
Neven Goršić wrote: Hi! In every manual and book I read only one way to make a raw string: r"e:\mm tests\1. exp files\5.MOC-1012.exp". I don't know how to make a string raw string if it is already contained in a variable. s.raw() or something like that ... Actually, there's no such thing as a

[Tutor] Raw string

2008-07-20 Thread Neven Goršić
Hi! In every manual and book I read only one way to make a raw string: r"e:\mm tests\1. exp files\5.MOC-1012.exp". I don't know how to make a string raw string if it is already contained in a variable. s.raw() or something like that ... Thank you very much PS. It seems like a very basic questi

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Alan G
> webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does. > > Thank you Ewald, for triggering the solution in my mind! > > Now, if anyone can explain why webbrowser.open_new() does the > character substitution thing it was doing (and th

Re: [Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Terry Carroll
On Mon, 8 Aug 2005, Tom Cloyd wrote: > So, thie > > webbrowser.open_new("file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.htm") > > does not work, but this > > webbrowser.open_new(r"file://C:\__Library\folders\02394 Yale Style > Manual\02394 Yale_Style_Manual.ht

[Tutor] raw string - solution to open_new() problem

2005-08-08 Thread Tom Cloyd
Ewald Ertl's reply to Don Parris's question about "r" operator gave me the idea of trying that out to solve my problem with file name scrambling when trying to use webbrowser.open_new() to open a file on my computer in a browser. It worked! So, thie webbrowser.open_new("file://C:\__Library\