using python to append a file

Emile van Sebille emile at fenx.com
Tue Jul 3 15:14:18 EDT 2001


>>> print open.__doc__
open(filename[, mode[, buffering]]) -> file object

Open a file.  The mode can be 'r', 'w' or 'a' for reading (default),
writing or appending.  The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing.  Add a 'b' to the mode for binary files.
Add a '+' to the mode to allow simultaneous reading and writing.
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size.

HTH

--

Emile van Sebille
emile at fenx.com

---------
"Thanh Le" <tle at firstlinux.net> wrote in message
news:13e6b4a6.0107031113.441998c at posting.google.com...
> I am new to Python and was wondering if anyone could show me a way to
> append a file (similar to the way Unix does by using >> ). I've tried
> using open('file','r+') method and it overwrote whatever i had in that
> file. I am sure there is a way to append a file, but  havent had much
> luck.
> Thanks in advance,
> Thanh





More information about the Python-list mailing list