class_docstr: This is the main class interface for Pexpect. Use this class to start
  and control child applications. 
class_docstr_tok: ["This","is","the","main","class","interface","for","Pexpect",".","Use","this","class","to","start","and","control","child","applications","."]
docstr: This gives control of the child process to the interactive user (the
  human at the keyboard). Keystrokes are sent to the child process, and
  the stdout and stderr output of the child process is printed. This
  simply echos the child stdout and child stderr to the real stdout and
  it echos the real stdin to the child stdin. When the user types the
  escape_character this method will return None. The escape_character
  will not be transmitted.  The default for escape_character is
  entered as ``Ctrl - ]``, the very same as BSD telnet. To prevent
  escaping, escape_character may be set to None.
  
  If a logfile is specified, then the data sent and received from the
  child process in interact mode is duplicated to the given log.
  
  You may pass in optional input and output filter functions. These
  functions should take bytes array and return bytes array too. Even
  with ``encoding='utf-8'`` support, meth:`interact` will always pass
  input_filter and output_filter bytes. You may need to wrap your
  function to decode and encode back to UTF-8.
  
  The output_filter will be passed all the output from the child process.
  The input_filter will be passed all the keyboard input from the user.
  The input_filter is run BEFORE the check for the escape_character.
  
  Note that if you change the window size of the parent the SIGWINCH
  signal will not be passed through to the child. If you want the child
  window size to change when the parent's window size changes then do
  something like the following example::
  
      import pexpect, struct, fcntl, termios, signal, sys
      def sigwinch_passthrough (sig, data):
          s = struct.pack("HHHH", 0, 0, 0, 0)
          a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
              termios.TIOCGWINSZ , s))
          if not p.closed:
              p.setwinsize(a[0],a[1])
  
      # Note this 'p' is global and used in sigwinch_passthrough.
      p = pexpect.spawn('/bin/bash')
      signal.signal(signal.SIGWINCH, sigwinch_passthrough)
      p.interact()
docstr_tok: ["This","gives","control","of","the","child","process","to","the","interactive","user","(","the","human","at","the","keyboard",")",".","Keystrokes","are","sent","to","the","child","process",",","and","the","stdout","and","stderr","output","of","the","child","process","is","printed",".","This","simply","echos","the","child","stdout","and","child","stderr","to","the","real","stdout","and","it","echos","the","real","stdin","to","the","child","stdin",".","When","the","user","types","the","escape_character","this","method","will","return","None",".","The","escape_character","will","not","be","transmitted",".","The","default","for","escape_character","is","entered","as","``","Ctrl","-","]","``",",","the","very","same","as","BSD","telnet",".","To","prevent","escaping",",","escape_character","may","be","set","to","None",".","If","a","logfile","is","specified",",","then","the","data","sent","and","received","from","the","child","process","in","interact","mode","is","duplicated","to","the","given","log",".","You","may","pass","in","optional","input","and","output","filter","functions",".","These","functions","should","take","bytes","array","and","return","bytes","array","too",".","Even","with","``","encoding='utf-8","'","``","support",",","meth",":","`","interact","`","will","always","pass","input_filter","and","output_filter","bytes",".","You","may","need","to","wrap","your","function","to","decode","and","encode","back","to","UTF-8",".","The","output_filter","will","be","passed","all","the","output","from","the","child","process",".","The","input_filter","will","be","passed","all","the","keyboard","input","from","the","user",".","The","input_filter","is","run","BEFORE","the","check","for","the","escape_character",".","Note","that","if","you","change","the","window","size","of","the","parent","the","SIGWINCH","signal","will","not","be","passed","through","to","the","child",".","If","you","want","the","child","window","size","to","change","when","the","parent","'s","window","size","changes","then","do","something","like","the","following","example",":",":","import","pexpect",",","struct",",","fcntl",",","termios",",","signal",",","sys","def","sigwinch_passthrough","(","sig",",","data",")",":","s","=","struct.pack","(","``","HHHH","''",",","0",",","0",",","0",",","0",")","a","=","struct.unpack","(","'hhhh","'",",","fcntl.ioctl","(","sys.stdout.fileno","(",")",",","termios.TIOCGWINSZ",",","s",")",")","if","not","p.closed",":","p.setwinsize","(","a","[","0","]",",","a","[","1","]",")","#","Note","this","'","p","'","is","global","and","used","in","sigwinch_passthrough",".","p","=","pexpect.spawn","(","'\/bin\/bash","'",")","signal.signal","(","signal.SIGWINCH",",","sigwinch_passthrough",")","p.interact","(",")"]
code: def interact(
      self,
      escape_character=chr(29),
      input_filter=None,
      output_filter=None,
  ):
      """This gives control of the child process to the interactive user (the
      human at the keyboard). Keystrokes are sent to the child process, and
      the stdout and stderr output of the child process is printed. This
      simply echos the child stdout and child stderr to the real stdout and
      it echos the real stdin to the child stdin. When the user types the
      escape_character this method will return None. The escape_character
      will not be transmitted.  The default for escape_character is
      entered as ``Ctrl - ]``, the very same as BSD telnet. To prevent
      escaping, escape_character may be set to None.
  
      If a logfile is specified, then the data sent and received from the
      child process in interact mode is duplicated to the given log.
  
      You may pass in optional input and output filter functions. These
      functions should take bytes array and return bytes array too. Even
      with ``encoding='utf-8'`` support, meth:`interact` will always pass
      input_filter and output_filter bytes. You may need to wrap your
      function to decode and encode back to UTF-8.
  
      The output_filter will be passed all the output from the child process.
      The input_filter will be passed all the keyboard input from the user.
      The input_filter is run BEFORE the check for the escape_character.
  
      Note that if you change the window size of the parent the SIGWINCH
      signal will not be passed through to the child. If you want the child
      window size to change when the parent's window size changes then do
      something like the following example::
  
          import pexpect, struct, fcntl, termios, signal, sys
          def sigwinch_passthrough (sig, data):
              s = struct.pack("HHHH", 0, 0, 0, 0)
              a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
                  termios.TIOCGWINSZ , s))
              if not p.closed:
                  p.setwinsize(a[0],a[1])
  
          # Note this 'p' is global and used in sigwinch_passthrough.
          p = pexpect.spawn('/bin/bash')
          signal.signal(signal.SIGWINCH, sigwinch_passthrough)
          p.interact()
      """
  
      # Flush the buffer.
      self.write_to_stdout(self.buffer)
      self.stdout.flush()
      self._buffer = self.buffer_type()
      mode = tty.tcgetattr(self.STDIN_FILENO)
      tty.setraw(self.STDIN_FILENO)
      if escape_character is not None and PY3:
          escape_character = escape_character.encode("latin-1")
      try:
          self.__interact_copy(
              escape_character, input_filter, output_filter
          )
      finally:
          tty.tcsetattr(self.STDIN_FILENO, tty.TCSAFLUSH, mode)
  
imports: import os
  import sys
  import time
  import pty
  import tty
  import errno
  import signal
  from contextlib import contextmanager
  import ptyprocess
  from ptyprocess.ptyprocess import use_native_pty_fork
  from .exceptions import ExceptionPexpect, EOF, TIMEOUT
  from .spawnbase import SpawnBase
  from .utils import which, split_command_line, select_ignore_interrupts, poll_ignore_interrupts
label_desc: Use image node_id 28 for calling the spawn obj's underlying member method code with example usage: obj.interact(escape_character, input_filter, output_filter) without return types