Fuzzyman wrote:
> Is there another way to shadow the sys module from a single namespace ?

I've never actually tried this, but try making a copy of the sys module 
then replacing the stdout object with your own object. Then you can 
replace "sys" of the namespace with your custom "sys" module. I guess it 
would look something like this:

import mysys     #My dummy sys module
import sys       #Actual sys module

#Copy sys module into dummy sys module
mysys.__dict__.update(sys.__dict__)

#Replace stdout with custom stdout
mysys.stdout = MyStdout()

#Replace sys of namespace
namespace.sys = mysys


This seems like it should work, however I don't know if copying the 
entire dictionary of one module to another is a safe thing to do.

-Farshid
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to