code: def clear(self):
          
          if hasattr(self.stdout, 'isatty') and self.stdout.isatty() or self.term_type == 'mintty':
              cmd, shell = {
                  'posix': ('clear', False),
                  'nt': ('cls', True),
                  'cygwin': (['echo', '-en', r'\ec'], False),
                  'mintty': (r'echo -en "\ec', False),
              }[self.term_type]
              subprocess.call(cmd, shell=shell, stdin=self.stdin, stdout=self.stdout, stderr=self.stderr)
docs: Clear the terminal screen.