Dan Guido wrote:
I'm trying to write a few methods that normalize Windows file paths.
I've gotten it to work in 99% of the cases, but it seems like my code
still chokes on '\x'. I've pasted my code below, can someone help me
figure out a better way to write this? This seems overly complicated
for such a simple problem...


[snip]

        test12 = "C:\windows\system32\xeuwhatever.sys" #this breaks everything

[snip]

--
Dan Guido

That is overly complicated. I would recommend you use either raw strings for windows paths, or double backslashes.

The problem you are observing is that \x (unlike the simpler ones such as \t) takes a hex number after the \x, so the whole thing would be, for example, \xa9. Because Python is looking for two hex digits after the back-slash, and not finding them, you get the error (long before your 'fix-it' routine gets a chance to run).

Hope this helps.

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to