'Simulate stdout and stderr'

def write(self, text, flush=False, error=False, prompt=False):

    if prompt:
        self.flush()
    if (not is_string(text)):
        text = to_text_string(text)
    self.__buffer.append(text)
    ts = time.time()
    if (flush or prompt):
        self.flush(error=error, prompt=prompt)
    elif ((ts - self.__timestamp) > 0.05):
        self.flush(error=error)
        self.__timestamp = ts
        self.__flushtimer.start(50)
