[IPython-user] Modifying stdout

Dan Yamins dyamins@gmail....
Wed Feb 11 10:02:25 CST 2009

> As you can see above, ipython's stdout is the bare python one.

Yes  -- I figured that out shortly after sending my first email ...

problem is that your class is missing a ton of other attributes.

Yes -- I figured this too.  So in my last email to list two days ago I
posted that I tried pretty much what you suggested:  something catches all
attributes except write and redirects them to the original stdout's
attribute.   (See below for the code).  It also fails, in the same way.

Is the reason that it fails that I haven't been carefl enough in catching
all attributes?  Or have I done it right and something more subtle going
on?  (What exactly does ipython do when you input "up" or "down" arrows?)



class multicaster():
    def __init__(self,filename,OldObject,New=False):
        self.file = filename
        self.old = OldObject
        if New:
            F = open(filename,'w')

            F.write('STARTING LOG: ' + time.strftime('%c %Z') + '\n')


    def __getattr__(self,name):
        if name != 'write':
            return self.old.__getattribute__(name)

    def write(self,s):
        F = open(self.file,'a')
        return self.old.write(s)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20090211/cf7e1b01/attachment.html 

More information about the IPython-user mailing list