What is print? A function?

Fredrik Lundh fredrik at pythonware.com
Sun Jan 23 13:33:58 EST 2005

Frans Englich wrote:

> I find this a nice solution. The most practical would be if it was possible to
> do this with print, of course. But print won't budge.

you can disable print, though:

    class dev_null:
        def write(self, text):
    sys.stdout = dev_null()

or pipe all print requests to a debug stream:

    if my_debug_flag:
        debug = sys.stdout
        debug = dev_null()

    print >>debug, "hello"
    print >>debug, "the value is", value

> Is it possible to create own statements, such that it would be possible to do:
> printDebug "test"



More information about the Python-list mailing list