I have this code:
class Sstdout(sys):
    def __init__(self,txtctrl):
        self.txtctrl = txtctrl
    def write(self,string):     
        self.txtctrl.write('hi '+string)
sys.stdout.write = Sstdout()    
os.dup2(some_odj.fileno(), sys.stdout.fileno())
Traceback (most recent call last):
    File "for_testing0.py", line 17, in <module>
        os.dup2(sock.fileno(), sys.stdout.fileno())
    AttributeError: 'Sstdout' object has no attribute 'fileno'
The question is how to correctly change only sys.stdout.write method ?
 
    