Encoding of file names
Kent Johnson
kent at kentsjohnson.com
Thu Dec 8 10:39:42 EST 2005
utabintarbo wrote:
> Here is my situation:
>
> I am trying to programatically access files created on an IBM AIX
> system, stored on a Sun OS 5.8 fileserver, through a samba-mapped drive
> on a Win32 system. Not confused? OK, let's move on... ;-)
>
> When I ask for an os.listdir() of a relevant directory, I get filenames
> with embedded escaped characters (ex.
> 'F07JS41C.04389525AA.UPR\xa6INR.E\xa6C-P.D11.081305.P2.KPF.model')
> which will read as "False" when applying an os.path.isfile() to it. I
> wish to apply some operations to these files, but am unable, since
> python (on Win32, at least) does not recognize this as a valid
> filename.
Just to eliminate the obvious, you are calling os.path.join() with the
parent name before calling isfile(), yes? Something like
for f in os.listdir(someDir):
fp = os.path.join(someDir, f)
if os.path.isfile(fp):
...
Kent
More information about the Python-list
mailing list