os.walk return hex excapes

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Nov 28 12:47:32 CET 2006


In <mailman.798.1164713355.32031.python-list at python.org>, Alex S wrote:

> os.walk return hex excape sequence inside a files name, and when i try
> to feed it back to os.remove i get 
> 
> OSError: [Errno 22] Invalid argument:
> 'C:\\Temp\\?p?\xbfS\xbf\xac?G\xaba ACDSee \xbb?a??n a???\xac\xb5\xbfn.exe'

There is no hex escape in that file name, just in the representation you
get in the error message.  The `repr()` form of a string contains just
ASCII, everything outside printable ASCII characters is printed as hex
escape so you can see what the string actually contains without being
interpreted by the shell, IDE or wherever the string is displayed.

How does the real file name look like?

Ciao,
	Marc 'BlackJack' Rintsch




More information about the Python-list mailing list