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

Terry Carroll carroll at tjc.com
Mon Aug 8 18:00:34 CEST 2005

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.htm")

I use forward slashes, it's simpler:

webbrowser.open_new("file://C:/__Library/folders/02394 Yale Style 
Manual/02394 Yale_Style_Manual.htm")

> Now, if anyone can explain why webbrowser.open_new() does the character  
> substitution thing it was doing (and thus becoming unable to locate the  
> file in question), I'm eager to hear it.

Your original contains "\02394 Yale Style".  "\023" equates to an octal 
23 (hex 13, decimal 19), rather than looking for a directory named:

 02394 Yale Style Manual

It's looking for

 X94 Yale Style Manual

Where "X" is actually a character with hex code 0x19.

More information about the Tutor mailing list