To redirect stdin,out

Thooney Millennier thooney at pk.highway.ne.jp
Mon Apr 26 11:24:57 EDT 1999


Hello,everyone.

I want to redirect standard input and output
to my C++ stream object and 
use something like PyRun_InteractiveLoop().

It seems we can redirect standard output by ...
(quoted from http://www.python.org/doc/FAQ.html)

      class StdoutCatcher:
        def __init__(self):
          self.data = ''
        def write(self, stuff):
          self.data = self.data +stuff
          ToCppObject(self.data)  #pass data to
C++ object

      import sys
      sys.stdout = StdoutCatcher()
      print 'foo'

I am at a loss how to redirect standard input.
If you know any solutions,Please Help!


Thanks for reading.

Thooney Millennier




More information about the Python-list mailing list