Problems reading fra sys.stdin and later on duing raw_input
alex at somewhere.round.here
Fri Mar 17 17:43:14 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.
> Is there *any* way I can solve this problem?
Maybe you could use ncurses to read from the keyboard. I've never used
it, but I'd be suprised if it goes through stdin. I tried writing
something, but it segfaults for some reason:
from pdb import set_trace
st = set_trace
def get_line (prompt):
screen = curses.initscr ()
# screen.cbreak () # screen has neither of these attributes...
# screen.noecho ()
response = screen.getstr (0,0)
if __name__ == '__main__':
std_input = sys.stdin.readlines ()
print 'This is what was piped:'
# print std_input
keyboard_input = get_line ('Enter something else: ')
print 'This is what was typed:'
This was based on the tutorial at http://python.org/doc/howto/curses/
More information about the Python-list