from string to raw string

Phd pyjunk at shaw.ca
Tue Dec 14 06:39:36 CET 2004


Hi,

I recently asked the same question, the response I got was that just use 
  the string. There is no raw string object so the conversion doesn't 
exist. As far as I know, I haven't run into any problem

Take a try. Please let me know if there is any problem with this approach.


Good luck



Dan Perl wrote:

> Is there a way to convert a regular string to a raw string so that one could 
> get from '\bblah' to r'\bblah' other than parsing the string and modifying 
> the escapes?
> 
> I am interested in this for the use of regular expressions.  I would like to 
> be able to accept re patterns as inputs either from a file or from a GUI 
> tool and I would like to allow those inputs as regular strings and not force 
> users to write patterns with double escapes.
> 
> I naively thought there could be utilities for such a conversion either in 
> the string module or the StringIO module but I don't see any utilities like 
> that.
> 
> So, any suggestions?
> 
> Dan 
> 
> 



More information about the Python-list mailing list