Larry Bates lbates at swamisoft.com
Sat Jun 26 01:21:36 CEST 2004

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]
    print "No input file specified, aborting"

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

Larry Bates
Syscon, Inc.

"Hegedus, Tamas ." <Hegedus.Tamas at mayo.edu> wrote in message
news:mailman.159.1088201404.27577.python-list at python.org...
> 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:
> --------------------------
> $cat text_file | my.py
>   Reading text_file...
>   text_file was loaded
>   Enter your comment:
> --------------------------
> Thanks for your help,
> Tamas

More information about the Python-list mailing list