Windows file paths, again

Jerry Hill malaclypse2 at gmail.com
Wed Oct 21 18:18:31 EDT 2009


On Wed, Oct 21, 2009 at 5:40 PM, Dan Guido <dguido at gmail.com> wrote:
> This doesn't give me quite the results I expected, so I'll have to
> take a closer look at my project as a whole tomorrow. The test cases
> clearly show the need for all the fancy parsing I'm doing on the path
> though.

To get back to what I think was your original question, there is an
easy way to take a string with control characters and turn it back
into a string with the control characters escaped, which could replace
your escape_dict and raw() function in normalize.py:

>>> s = 'Foo\t\n\n\x12Bar'
>>> print s
Foo	

Bar
>>> r = s.encode('string-escape')
>>> print r
Foo\t\n\n\x12Bar
>>>

(Python 2.6.1 on windows XP)

More generally, it sounds like you have some bad data in either the
registry, or your ini file.  You shouldn't have control characters in
there (unless you really have directories with control characters in
their names).  If you have control over how those values are written,
you should probably fix the bad data at the source instead of fixing
it as you pull it back in.

-- 
Jerry



More information about the Python-list mailing list