Writing at the beginning of a file

Grant Edwards grante at visi.com
Wed Sep 14 10:44:21 EDT 2005


On 2005-09-14, Thierry Lam <lamthierry at gmail.com> wrote:
> Let's say I already wrote a file and have the following:
>
> testing
> testing testing
> testing testing testing
>
> Is there an easy way to write something of variable length at the top
> of the file?

No.

[...]

> The other way to do what I want is to write the whole thing to a new
> file, but I want to skip that method if there's an alternative way.

There isn't.

> Another way of doing it is to buffer the whole file writing into some
> variable, but that means I have to change 2000+ lines of codes and
> change fp.write() to something else.
>
> Any suggestions please?

Looks like you've figured it out already.

-- 
Grant Edwards                   grante             Yow!  Are you selling NYLON
                                  at               OIL WELLS?? If so, we can
                               visi.com            use TWO DOZEN!!



More information about the Python-list mailing list