Source code for moe.writer.echoer

'''The echoer module contains an implementation of Writer which prints strings to stdout.'''
import sys


[docs]class Echoer(): '''Writer that prints strings to a given stream. Args: stream (object, optional): Defaults to sys.stdout. Stream to which to write.''' def __init__(self, stream: object = sys.stdout) -> None: self.stream = stream
[docs] def set_stream(self, stream: object) -> object: '''Define the stream to which to write the strings. Args: stream (object): Stream to which to write to. Returns: object: The Echoer instance''' self.stream = stream return self
[docs] def write(self, string: str) -> None: '''Write the string to a given stream Args: string (str): string to write.''' self.stream.write(string)