Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Marco Newsgroups: comp.lang.python Subject: Built-in open() with buffering > 1 Date: Fri, 24 Aug 2012 06:35:27 +0200 Organization: Aioe.org NNTP Server Lines: 26 Message-ID: NNTP-Posting-Host: jkLVTVqcLfHLY4STqRGQsQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.python:27777 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." So I thought this size was the number of bytes or chars, but it is not: >>> f = open('myfile', 'w', buffering=2) >>> f.write('a') 1 >>> open('myfile').read() '' >>> f.write('b') 1 >>> open('myfile').read() '' >>> f.write('cdefghi\n') 8 >>> open('myfile').read() '' >>> f.flush() >>> open('myfile').read() 'abcdefghi\n' Regards, Marco