[IronPython] sys.path.append bug?
dinov at exchange.microsoft.com
Mon Jun 5 09:28:53 PDT 2006
Seo's pointing out that you're building up a string as-if the user had typed it into the console, and that string contains non-escaped characters. So you're putting in the equivalent of:
'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CNU2Demo\CNU2Demo\Bin\Debug')
If you typed this at the console then the \B in \Bin\Debug would turn into the backspace escape character, and the path wouldn't be correct. If you change this to:
ipEngine1.Execute("sys.path.append(r'" + Paths.MiscDirs.myapppath + "')");
then you should get the right behavior (note you have the @ don't escape character for C#, and I just moved that to being in the embedded string that you're passing to Python (the r string form). You could also still have the @ but in the sample code you're not really using it.
Alternately you could do the escaping yourself.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of JoeSox
Sent: Saturday, June 03, 2006 2:41 AM
To: Discussion of IronPython
Subject: Re: [IronPython] sys.path.append bug?
On 6/3/06, Sanghyeon Seo <sanxiyn at gmail.com> wrote:
> 2006/6/3, JoeSox <joesox at gmail.com>:
> > It appears the "CNU2Demo\x08in\\Debug" should read "CNU2Demo\\bin\\Debug"
> >>> '\b'
> If you use PythonEngine.Execute, you should escape Python string.
I don't understand what you are saying because I used .Execute and it stored the value incorrectly.
users mailing list
users at lists.ironpython.com
More information about the users