Ido Yehieli wrote: > I'm sorry, but i don't see how this will solve the problem? It is > exactly the same, only now you've replaced everything in sys except > just sys.stdout?
In the solution above (which I haven't had a chance to test) you're just chaning hte reference to sys to point to a different module, so you're not messing with sys itself. This won't affect other code that uses the sys module. Because of the builtin status of the sys module I'm not *convinced* it will work. I'll try it though. > At any rate, perhapse the code you will write will be more maintainable > if instead of redirecting sys.stdout for some of the code just use a > different function (instead of print) for the times where you wish it > to be redirected somewhere else? it will probably make your code > longer, but the maintainer will have one less "gotcha" to worry about a > few months/years down the road. perhapse it is best to not do the > "clever" thing this time ;-) ? We're executing code from another module that uses the print statement a lot. That module isn't our code - other wise we wouldn't have a problem. :-) Changing the module will mean a great deal more to maintain, not less. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list