2007/11/9, Guido van Rossum <[EMAIL PROTECTED]>:

> Well, passing '1' as the buffer size to open() is supposed to set the
> buffer size to the default value (typically 8K)

OK, my new patch does that. At the momment it is buffering for
interactive mode as well as for scripts instead of buffering only for
the latter.

Python 3.0a1 (py3k, Nov  9 2007, 11:09:49)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print('python is flushing when there\' a new line')
python is flushing when there' a new line
>>> print('python is not flushing when new line is gone',end='')
>>> print('')
python is not flushing when new line is gone
>>> ret=sys.stdout.write('python is not flushing when new line is gone')
>>> sys.stdout.flush()
python is not flushing when new line is gone>>><ENTER>
>>> ret=sys.stdout.write('python is flushing when there\s a new line\n')e
python is flushing when there\s a new line
>>>

But, is this really what we want to do? When I run that code:
-----------------------
#include <stdio.h>
#include <string.h>
int main(void)
{
   char *buf="write() is flushing!";
   char *buf2="x";
   write(1,buf,strlen(buf));
   sleep(3);
   write(1,buf2,strlen(buf2));
   sleep(3);
   // printf("printf() requires a new line to flush");
   return 0;
}
--------------------

each write() is writing before sleep() even though there's no flush().
Do we want to ask every programmer to flush everytime there's no new line?
If not, python should flush for every string > 0 bytes, than for
string > 1 byte.

> *and* set a special
> flag that forces a flush() whenever a line end is written. But this
> isn't implemented; instead, it just flushes after each character...

Isn't it rather flushing after each print() or write() call?


Wojtek Walczak

Attachment: py3k-print_2nd.patch
Description: Binary data

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to