Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unbuffered stdout?

577 views
Skip to first unread message

Aaron Watters

unread,
Aug 5, 1996, 3:00:00 AM8/5/96
to

Quicky: how do you do unbuffered stdout?
I don't see any setbuf anywhere and I don't wanna
hafta flush() everywhere. fcntl? (unix/solaris)
thanks,
aaron watters.

Guido van Rossum

unread,
Aug 5, 1996, 3:00:00 AM8/5/96
to

> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)

Use 0 for the optional 3rd arg to open() (and most other things that
return a standard file object). For stdout/stderr, use "python -u".
It is done this way because stdio crashes spectacularly (on some
systems) if you call set*buf() after doing any I/O, and there's no
portable way to test whether it is still allowed to call it, so I would
have to maintain my own state variable just to implement a safe
setbuf() method... Adding it to open made a lot more sense.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Dave Mitchell

unread,
Aug 5, 1996, 3:00:00 AM8/5/96
to


On Mon, 5 Aug 1996, Aaron Watters wrote:

> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)

> thanks,
> aaron watters.
>


Not sure the right way to do this, but open() and fdopen() both
take a third argument that is the buffersize.

Dave

tri...@speedy.supelec.fr

unread,
Aug 5, 1996, 3:00:00 AM8/5/96
to

Aaron Watters (a...@big.att.com) wrote:
: Quicky: how do you do unbuffered stdout?
: I don't see any setbuf anywhere and I don't wanna
: hafta flush() everywhere. fcntl? (unix/solaris)
: thanks,
: aaron watters.

you can use the -u switch or setenv PYTHONUNBUFFERED 1, or even modify
main.c, or sysinit() in sysmodule.c so that it creates unbuffered sys.stdout
and sys.stderr, or add setbuf and setvbuf methods to the Python file type.
My guess is you'll prefer the 2 first ways :-)

Benoit

Robin Friedrich

unread,
Aug 6, 1996, 3:00:00 AM8/6/96
to

Aaron Watters <a...@big.att.com> writes:

>
> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)
> thanks,
> aaron watters.

How about

python -u

0 new messages