Intercept and Tag STDOUT values

Wes S. MornIHATESPAMThdr at
Wed Oct 13 08:43:32 CEST 2004

Many thanks for the first reply of help.

On this second part, I don't fully understand what you mean...I am, as I
have previously stated, pretty new to Python and have not yet learned
anything about file operations.


"Andrew Durdin" <adurdin at> wrote in message
news:mailman.4809.1097645400.5135.python-list at
> Further to my last reply: perhaps a better solution overall would be
> to create a class (let's call it TaggedFile) that supports the
> appropriate methods for file-like behaviour, and wraps any file
> (keeping a reference to it in the "wrapped_file" attribute) with the
> tagging you want. Then to do the actual redirection:
> tagged_stdout = TaggedFile(sys.stdout)
> sys.stdout = tagged_stdout
> # other code here
> sys.stdout = tagged_stdout.wrapped_file
> It will then be much clearer that the redirection is occurring.

More information about the Python-list mailing list