How totell a binary file from a nonbinary file.

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Sun Oct 29 12:35:17 EST 2000


Err... All files are "binary".  "Text files" are binary files that follow a
convention.  You will have to scan a file (or a good part of it) to
determine if it follows the convention.  That convention is that there's LF
(ascii 10) characters every so often and in DOS/Windows these are preceeded
by CR (ascii 13).  There's also a EOF (ascii 27) as the last byte of the
file (not always, I think) and you should not find any other lower ascii
(less than or equal to 31) characters in the file.

Of course, there's always the possibility of freak occurences, so that's all
the [useful] advice I can give!

pretending-to-know-something-ly y'rs,

--
----------------------------------------------------------------------
Olivier A. Dagenais - Software Architect and Developer
"Someone called 'Type your name here' is impersonating me on the
internet and is posting exactly the same things I am posting!"


"Thaddeus L. Olczyk" <olczyk at interaccess.com> wrote in message
news:39fe4f47.100441671 at nntp.interaccess.com...
> There are some changes that I have to make to s directory of files (
> in python of course ). Is there some simple way of telling whether
> a file is binary or not (from python of course )?
>





More information about the Python-list mailing list