safest way to open files on all platforms

rbt rbt at athop1.ath.vt.edu
Mon Feb 14 09:14:30 EST 2005


I believe that this is the safest way to open files on Windows, Linux, 
Mac and Unix, but I wanted to ask here just to be sure:

fp = file('filename', 'rb')

The 'b' on the end being the most important ingredient (especially on 
Windows as a simple 'r' on a binary file might cause some sort of 
corruption).

Anyway, am I right in saying this? That 'rb' is the safest way to open 
files for reading and that it should work well on *all* Python supported 
platforms?

Many thanks,

RBT



More information about the Python-list mailing list