Problems reading fra sys.stdin and later on duing raw_input

Peter Kristensen pkr at
Fri Mar 17 13:59:13 CET 2000


I want to read a file from sys.stdin and then later on do a
raw_input. But I get an error because sys.stdin is closed after the
file is read.

Here is an example that illustrates the problem.

        #!/usr/bin/env python

        import sys

        lines = sys.stdin.readlines()
        for line in lines:
            print line

        a = raw_input('Prompt: ')
        print a

pkr at perm:~> echo -n "test" | /tmp/ 
Prompt: Traceback (innermost last):
  File "/tmp/", line 9, in ?
    a = raw_input('Prompt: ')
EOFError: EOF when reading a line

Is there *any* way I can solve this problem?

Btw, I use python-1.5.2 on Linux 2 and Solaris 7

Peter Kristensen

More information about the Python-list mailing list