469,327 Members | 1,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Explane File modes please --

What exactly does the underlined text mean. w & a obviously mean you are
going to update the file.
So what does the + mean on w+ & a+ mean?
Also please could someone explain w+ truncating the file.
I may just be dense so please be patient :)

-------------------------------------------------------------------------
[Copy from python 2.3.3 help file]
file( filename [, mode [, bufsize ] ] )

Return a new file object (described earlier under Built-in Types). The
first two arguments are the same as for stdio's fopen(): filename is the
file name to be opened, mode indicates how the file is to be opened: 'r'
for reading, 'w' for writing (truncating an existing file), and 'a'
opens it for appending (which on some Unix systems means that all writes
append to the end of the file, regardless of the current seek position).

Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+'
truncates the file). Append 'b' to the mode to open the file in binary
mode, on systems that differentiate between binary and text files (else
it is ignored). If the file cannot be opened, IOError is raised.
Jul 18 '05 #1
0 1181

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by simon place | last post: by
reply views Thread by pxlpluker | last post: by
1 post views Thread by Phil S | last post: by
6 posts views Thread by Jakob Bieling | last post: by
5 posts views Thread by erikcw | last post: by
4 posts views Thread by HMS Surprise | last post: by
10 posts views Thread by rory | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.