Built-in open() with buffering > 1

Marco marco_u at nsgmail.com
Fri Aug 24 01:21:36 EDT 2012


On 08/24/2012 06:35 AM, Marco wrote:
> Please, can anyone explain me the meaning of the
> "buffering > 1" in the built-in open()?
> The doc says: "...and an integer > 1 to indicate the size
> of a fixed-size chunk buffer."

Sorry, I get it:

 >>> f = open('myfile', 'w', buffering=2)
 >>> f._CHUNK_SIZE = 5
 >>> for i in range(6):
...     n = f.write(str(i))
...     print(i, open('myfile').read(), sep=':')
...
0:
1:
2:
3:
4:
5:012345




More information about the Python-list mailing list