Binary or ascii file?

effbot at pythonware.com effbot at pythonware.com
Fri Sep 8 10:41:47 CEST 2000


Steven Adams wrote:
> it shouldn't be too hard to find out whether a file is binary
> or not, since AFAIK Windows sets a flag to show whether a file
> is an executable/binary or not. is that correct?

nope.

Unix has an executable flag, but text files can be executable too
(scripts), and binary files don't have to be executable (data files).

you can look at the file extension, or look at the first 100-1000
bytes of the file and see if it looks like plain text, but there's
no 100% reliable solution to this problem.

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list