Package grizzled :: Package io :: Class MultiWriter
[hide private]
[frames] | no frames]

Class MultiWriter

source code

object --+
         |
        MultiWriter

Wraps multiple file-like objects so that they all may be written at once. For example, the following code arranges to have anything written to sys.stdout go to sys.stdout and to a temporary file:

import sys
from grizzled.io import MultiWriter

sys.stdout = MultiWriter(sys.__stdout__, open('/tmp/log', 'w'))
Instance Methods [hide private]
 
__init__(self, *args)
Create a new MultiWriter object to wrap one or more file-like objects.
source code
 
write(self, buf)
Write the specified buffer to the wrapped files.
source code
 
flush(self)
Force a flush.
source code
 
close(self)
Close all contained files.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args)
(Constructor)

source code 
Create a new MultiWriter object to wrap one or more file-like objects.
Parameters:
  • args (iterable) - One or more file-like objects to wrap
Overrides: object.__init__

write(self, buf)

source code 
Write the specified buffer to the wrapped files.
Parameters:
  • buf (str or bytes) - buffer to write