WRITING FILES

Sergio Boix Moriano smoriano at sicon.net
Thu Oct 19 16:15:55 CEST 2000


Sergio Boix Moriano wrote:

> Hi all,
>
>     I want to make a procedure to append lines to a file, in the
> position i want.
>
>     I've tried to do this opening the file in mode "r+", but if i do
> this, it writes in the document from a position x, but overwritting the
> text that is in the document. If i open de document with (a+) it writes
> always at the end of the document.
>
>     What i'm doing bad?

     Hi again

        I solved it, i open the file in mode 'w+', i stored the lines used
the readlines() function, and then i modify the list doing inserts, and
finally i write this list to the file.

    But, is there another way to do this?





More information about the Python-list mailing list