exclude binary files from os.walk

Dan Perl danperl at rogers.com
Wed Jan 26 18:25:09 EST 2005

"rbt" <rbt at athop1.ath.vt.edu> wrote in message 
news:ct94j7$15a$1 at solaris.cc.vt.edu...
> Is there an easy way to exclude binary files (I'm working on Windows XP) 
> from the file list returned by os.walk()?
> Also, when reading files and you're unsure as to whether or not they are 
> ascii or binary, I've always thought it safer to 'rb' on the read, is this 
> correct... and if so, what's the reasoning behind this? Again all of this 
> pertains to files on Windows XP and Python 2.4

Please clarify: is your question about identifying binary (non-ascii) files 
or about using os.walk? 

More information about the Python-list mailing list