Documentation? file/open with tea

Thomas D'Tak outpost at
Sun Sep 19 22:42:02 CEST 2004

On Sun, 19 Sep 2004 11:40:37 -0800, Eric Pederson wrote:
> I've come across this file operation in others' code and have not seen any documentation for it: 
> the use of "t" in the mode of file opening, such as:
> f1=open(somefile, 'at')
> f2=open(otherfile, 'rt')
> Is this merely another shorthand for a binary mode, or is there more going on with 't'?

No, but for 'text' resp. 'translated' mode 
(though it comes from C/C++ on Windows).

Python's documentation on 'open()' (resp. 'file()') says, that the first
two arguments are the same as for C's stdio's 'fopen()'. And on Windows
you will often find that fopen() supports 't' as a mode extension (like
the well known 'b' for binary mode):

  'b': open file in binary (untranslated) mode

  't': open file in text (translated) mode; 
       (e.g. look for Ctrl-z as EOF marker)


Python's file() resp. open():

(E.g.) Visual C++'s fopen():

HTH, Th.

More information about the Python-list mailing list