Python Plumber's Helpers

Copyright © 2001, Chris Gonnerman


These modules define some interesting file-like objects: This module provides a convenient file-like object (writing only) which dates output lines automatically.

There is also a public function, logtime(), which returns the current date in the format used by the LogFile class.


import sys
from Logger import LogFile

sys.stderr = LogFile(open("example.log", "a"))

NWayOutput: This module implements a class, NWayOutput, which must be instantiated with one or more file-like objects (capable of write). The file-like objects may be given as a tuple, list, or as multiple arguments.

Assuming you have done this:

import NWayOutput

nf = NWayOutput.NWayOutput(file1, file2, file3)
any call of nf.write() calls file1.write(), file2.write(), and file3.write() with the given arguments.

What's it good for? How about this:

import sys
from NWayOutput import NWayOutput

sys.stderr = \
  NWayOutput(sys.stderr, open("logfile.txt", "w"))
As you can imagine, this is very handy combined with



This package includes a Distutils-based installer. Assuming you are running Python 2.0 or higher or have installed the Distutils, you can just do this:

python install
(as root/Adminstrator if necessary) and you're done.

Alternately, just copy the included and to your site-packages directory or somewhere else in sys.path.