Package: python2.4
Version: 2.4.4-1
Severity: wishlist

Hello,

I noticed that sys.stdin is fully buffered even when reading from a
terminal, which contrasts a bit with what is usual in most other
languages and command line tools:

Given:

import sys
for i in sys.stdin:
        print "->", i[:-1]

You get:

$ python /tmp/foo.py
a
b
c
-> a
-> b
-> c


But for example in Perl:

while (<>)
{
        print "-> ", $_
}

You get:

$ perl /tmp/foo.pl
a
-> a
b
-> b
c
-> c


Or C:

#include <stdio.h>
main()
{
        while (!feof(stdin))
        {
                char buf[1000];
                fgets(buf, 1000, stdin);
                fputs("-> ", stdout);
                fputs(buf, stdout);
        }
        return 0;
}

You get:

$ gcc /tmp/foo.c -o /tmp/foo
$ /tmp/foo
a
-> a
b
-> b
c
-> c
-> c



Best regards,

Enrico Zini

-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.19.1enrico
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)

Versions of packages python2.4 depends on:
ii  libbz2-1.0                   1.0.3-6     high-quality block-sorting file co
ii  libc6                        2.3.6.ds1-8 GNU C Library: Shared libraries
ii  libdb4.4                     4.4.20-8    Berkeley v4.4 Database Libraries [
ii  libncursesw5                 5.5-5       Shared libraries for terminal hand
ii  libreadline5                 5.2-2       GNU readline and history libraries
ii  libssl0.9.8                  0.9.8c-4    SSL shared libraries
ii  mime-support                 3.39-1      MIME files 'mime.types' & 'mailcap
ii  python2.4-minimal            2.4.4-1     A minimal subset of the Python lan

python2.4 recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to