[Zope] Writing to LocalFS

Rik Hoekstra rik.hoekstra@inghist.nl
Thu, 22 Jun 2000 17:47:28 +0200



>(thanks to Jonathon and Dieter... for the permissions problem. That
>did the trick)
>
>Again, after some searching, I am looking for the syntax to write  a
>file / append to a file in a Local File System.
>
>This is certainly where my Python days seem to slow my down b/c I
>would have just:
>
>contents = open('/path/file.txt', "r")
>
>to read and
>
>contents = open('/path/file.txt', "a")
>
>to append.
>
>I am sure that I am missing some bit of Zope Zen here...
>
>Please point me in the right direction...
>



Not sure if this was the question, but here's a relevant quote from the
python library reference
<http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-139>

<quote>
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.
</quote>

hth

Rik