Binary or ascii file?

effbot at effbot at
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?


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.


<!-- (the eff-bot guide to) the standard python library:

Sent via
Before you buy.

More information about the Python-list mailing list