code: def __init__(self, file=None, stringio=False, encoding=None):
      if file is None:
          if stringio:
              self.stringio = file = py.io.TextIO()
          else:
              from sys import stdout as file
      elif py.builtin.callable(file) and not (
          hasattr(file, "write") and hasattr(file, "flush")
      ):
          file = WriteFile(file, encoding=encoding)
      if hasattr(file, "isatty") and file.isatty() and colorama:
          file = colorama.AnsiToWin32(file).stream
      self.encoding = encoding or getattr(file, "encoding", "utf-8")
      self._file = file
      self.hasmarkup = should_do_markup(file)
      self._lastlen = 0
      self._chars_on_current_line = 0
      self._width_of_current_line = 0
  
imports: import sys, os, unicodedata
  import py
  from py.builtin import text, bytes
label_desc: Use image node_id 1 to create a new TerminalWriter object from inherited base classes: object with example: obj = TerminalWriter(file, stringio, encoding)