[Tutor] How to make the difference between binary and text files ?

Dominique mydomdom at gmail.com
Sat Apr 4 13:07:55 CEST 2009


Hello,

I am developing a very small multi-platform app to search for a specific word or
expression in files located in a drive or directory.
So I need to open files to search for the word.

I read that opening a binary file as a text file (open(filename, 'r')) may
corrupt the file.
Consequently, before opening the file, I'd like to test it to adapt the opening
mode ('r' or 'rb').

Is there a way to make the difference between binary and text files ?

Thanks in advance for your help.

Dominique




More information about the Tutor mailing list