[Tutor] code improvement for beginner ?

Roel Schroeven rschroev_nospam_ml at fastmail.fm
Tue Oct 11 10:28:30 CEST 2005

Kent Johnson wrote:
> Roel Schroeven wrote:
>> Danny Yoo wrote:
>>> Looking at pageimgs(): I'm not sure what 't' means in the open
>>> statement:
>>> f = open(filename, "rt")
>> It's not a typo. 't' opens the file in text mode.
> Are you sure? Is that documented anywhere?

I thought it was, but actually it seems it's not. I know it from fopen
in C on Windows; it is documented in MSDN.

> Text mode is the default, you have to specify the 'b' if you want
> binary mode.

Indeed, so it seems. I just always use 't' since I do that in C too, and
Python never complained about it.

If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven

More information about the Tutor mailing list