Reading From stdin After Command Line Redirection
Chris Angelico
rosuav at gmail.com
Wed Oct 23 16:40:04 EDT 2013
On Thu, Oct 24, 2013 at 4:25 AM, Tim Daneliuk <tundra at tundraware.com> wrote:
> I have a program that runs like this:
>
> foo.py <inputfile
>
> I want to reconnect stdin to the tty as usual after 'inputfile'
> has been read so that things like raw_input and getpass
> will work as expected.
>
> So, after I do .... = sys.stdin.readlines(), how to I reopen
> stdin in its nonredirected mode?
You fundamentally can't reopen "stdin", as that will just be your
input file. What you want to do is open the console (TTY) itself. What
platform are you on?
ChrisA
More information about the Python-list
mailing list