To redirect stdin,out

Stephan Houben stephan at pcrm.win.tue.nl
Tue Apr 27 02:28:25 EDT 1999


Thooney Millennier <thooney at pk.highway.ne.jp> writes:

> 
>       import sys
>       sys.stdout = StdoutCatcher()
>       print 'foo'
> 
> I am at a loss how to redirect standard input.
> If you know any solutions,Please Help!

Well, I tried the obvious analog of this code snippet:

  import sys
  sys.stdin = open("one_of_my_files.txt")
  print raw_input() 

And it seemded to work fine. Am I missing something?

Greetings,

Stephan




More information about the Python-list mailing list