Documentation for C's fopen():
---
r Open text file for reading. The stream is positioned at the beginning
of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing. The
stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does not
exist, otherwise it is truncated. The stream is positioned at the
beginning of the file.
a Open for writing. The file is created if it does not exist. The stream
is positioned at the end of the file.
a+ Open for reading and writing. The file is created if it does not
exist. The stream is positioned at the end of the file.
======================================================
In Python: http://docs.python.org/library/functions.html#open
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; on systems that don’t have this distinction, adding the 'b' has no effect.
In addition to the standard fopen() values mode may be 'U' or 'rU' . Python is usually built with universal newline support; supplying 'U' opens the file as a text file, but lines may be terminated by any of the following: the Unix end-of-line convention '/n' , the Macintosh convention '/r' , or the Windows convention '/r/n' . All of these external representations are seen as '/n' by the Python program. If Python is built without universal newline support a mode with 'U' is the same as normal text mode. Note that file objects so opened also have an attribute called newlines which has a value of None (if no newlines have yet been seen), '/n' , '/r' , '/r/n' , or a tuple containing all the newline types seen.
Python enforces that the mode, after stripping 'U' , begins with 'r' , 'w' or 'a' .