(std)input

H

Hegedus, Tamas .

Dear All,

I am not a programmer, and I could not find out the solution of the following problem:
I would like to pipe a program output to my python script; after it receives the EOF, I would like to get input from the users.
I do not know the programmer expression of this process. Something like that: I would like to set the stdin back to the keyboard.

A stupid example:
 
L

Larry Bates

You might think of this a different way.

python my.py text_file
Enter your comment:

Have the python program pick up the file from
the argument list and read its contents, then
use raw_input to prompt the user.

You can do this with something like:

import sys
try: input_file=sys.argv[1]
except:
print "No input file specified, aborting"
sys.exit(2)

fp=open(input_file, 'r')
print "Reading text_file..."
data=fp.read()
fp.close()
print "text_file was loaded"
comment=raw_input("Enter your comment")

HTH,
Larry Bates
Syscon, Inc.


Hegedus said:
Dear All,

I am not a programmer, and I could not find out the solution of the following problem:
I would like to pipe a program output to my python script; after it
receives the EOF, I would like to get input from the users.
I do not know the programmer expression of this process. Something like
that: I would like to set the stdin back to the keyboard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top