how to save strings to a temporary buffer?

Roman Suzi rnd at
Wed Jul 18 16:50:07 EDT 2001

On Wed, 18 Jul 2001 ed_tsang at wrote:

>How can I save string to a tempororay buffer and then write it to a
>file afterwards?
>I have a function that output a formatted string each time it is
>called; but instead of open a file and write it each time; I would
>like to save these strings to a , may be a tmeporory buffer, and then
>write it to a file when everythign is completed... how cna I do that?

You can specify buffer size in open() to the size you want.
This will have the effect you want.

f = open("file", "w", 100000)

f.flush()  # when you want to write buffer to disk



Sincerely yours, Roman Suzi
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at _/
_/ Wednesday, July 18, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Hard work never killed anyone, but why chance it?" _/

More information about the Python-list mailing list