[Tutor] Create text file (original) (raw)

Dick Moores rdm at rcblue.com
Thu Jul 1 15:00:30 EDT 2004


Bob Gailer wrote at 06:44 7/1/2004:

At 07:36 AM 7/1/2004, Lloyd Kvam wrote:

Simply use the Python file object with a t appended to the mode: textfile = file('newfile.txt','wt') Interesting (1) that wt is not documented, and (2) apparantly anything can follow the w without error.

I found a mention on p. 188 in Python in a Nutshell:

"The mode string may also have any of the values just explained followed by a b or t. b denotes binary mode, while t denotes text mode. When the mode string has neither b nor t, the default is text mode (i.e., 'r' is like 'rt', 'wt' is like 'wt', and so on)."

Dick Moores



More information about the Tutor mailing list