On 14-Jun-11 15:48, Steven D'Aprano wrote:

Normally you would do this by redirecting standard input. What operating
system are you using? In Linux, you would do something like:


# run script foo.py taking input from the output of bar.py
foo.py < bar.py

Actually, no, that will send the *source code* of bar.py as the input to foo.py. I think you mean:

bar.py | foo.py

which also should work in DOS as well (although less efficiently).

However, I don't know if this will actually work for raw_input. It may
not. Try it and see.

It should.


Perhaps a better way is to have your program accept a user name and
password on the command line, and only prompt for them if not given.
Then you can say:

foo.py --user=fred --password="y8Mr3@hzi"

This is one way. Another would be to use the subprocess module in Python which will let one program invoke another program, and have a file-like object on which it can write data, which the child program will see as its standard input (and read in to raw_input).

--
Steve Willoughby / st...@alchemy.com
"A ship in harbor is safe, but that is not what ships are built for."
PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to