(self, banner=None, exitmsg=None)
Closely emulate the interactive Python console.

        The optional banner argument specifies the banner to print
        before the first interaction; by default it prints a banner
        similar to the one printed by the real Python interpreter,
        followed by the current class name in parentheses (so as not
        to confuse this with the real interpreter -- since it's so
        close!).

        The optional exitmsg argument specifies the exit message
        printed when exiting. Pass the empty string to suppress
        printing an exit message. If exitmsg is not given or None,
        a default message is printed.
Closely emulate the interactive Python console.
Closely emulate the interactive Python console .
def interact(self, banner=None, exitmsg=None):
        """Closely emulate the interactive Python console.

        The optional banner argument specifies the banner to print
        before the first interaction; by default it prints a banner
        similar to the one printed by the real Python interpreter,
        followed by the current class name in parentheses (so as not
        to confuse this with the real interpreter -- since it's so
        close!).

        The optional exitmsg argument specifies the exit message
        printed when exiting. Pass the empty string to suppress
        printing an exit message. If exitmsg is not given or None,
        a default message is printed.

        """
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "
        cprt = 'Type "help", "copyright", "credits" or "license" for more information.'
        if banner is None:
            self.write("Python %s on %s\n%s\n(%s)\n" %
                       (sys.version, sys.platform, cprt,
                        self.__class__.__name__))
        elif banner:
            self.write("%s\n" % str(banner))
        more = 0
        while 1:
            try:
                if more:
                    prompt = sys.ps2
                else:
                    prompt = sys.ps1
                try:
                    line = self.raw_input(prompt)
                except EOFError:
                    self.write("\n")
                    break
                else:
                    more = self.push(line)
            except KeyboardInterrupt:
                self.write("\nKeyboardInterrupt\n")
                self.resetbuffer()
                more = 0
        if exitmsg is None:
            self.write('now exiting %s...\n' % self.__class__.__name__)
        elif exitmsg != '':
            self.write('%s\n' % exitmsg)
def interact ( self , banner = None , exitmsg = None ) : try : sys . ps1 except AttributeError : sys . ps1 = ">>> " try : sys . ps2 except AttributeError : sys . ps2 = "... " cprt = 'Type "help", "copyright", "credits" or "license" for more information.' if banner is None : self . write ( "Python %s on %s\n%s\n(%s)\n" % ( sys . version , sys . platform , cprt , self . __class__ . __name__ ) ) elif banner : self . write ( "%s\n" % str ( banner ) ) more = 0 while 1 : try : if more : prompt = sys . ps2 else : prompt = sys . ps1 try : line = self . raw_input ( prompt ) except EOFError : self . write ( "\n" ) break else : more = self . push ( line ) except KeyboardInterrupt : self . write ( "\nKeyboardInterrupt\n" ) self . resetbuffer ( ) more = 0 if exitmsg is None : self . write ( 'now exiting %s...\n' % self . __class__ . __name__ ) elif exitmsg != '' : self . write ( '%s\n' % exitmsg )