exclude binary files from os.walk

Larry Bates lbates at syscononline.com
Wed Jan 26 17:49:51 EST 2005


There's no definitive way of telling a file is
"non-ascii".  Bytes in a binary file define
perfectly good ascii characters.  Windows
depends on file extensions to try to keep track
of the "type" of data in a file, but that isn't
foolproof.  I can rename a plain ascii file with
a .EXE extension.

We could be of more help, if you would take the
time to explain a little about what you are trying
to do.

Larry Bates

rbt wrote:
> Grant Edwards wrote:
> 
>> On 2005-01-26, rbt <rbt at athop1.ath.vt.edu> wrote:
>>
>>
>>> Is there an easy way to exclude binary files (I'm working on
>>> Windows XP) from the file list returned by os.walk()?
>>
>>
>>
>> Sure, assuming you can provide a rigorous definition of 'binary
>> files'.  :)
> 
> 
> non-ascii



More information about the Python-list mailing list