MCPcopy Index your code
hub / github.com/python/cpython / interact

Function interact

Lib/code.py:358–382  ·  view source on GitHub ↗

Closely emulate the interactive Python interpreter. This is a backwards compatible interface to the InteractiveConsole class. When readfunc is not specified, it attempts to import the readline module to enable GNU readline if it is available. Arguments (all optional, all default t

(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=False)

Source from the content-addressed store, hash-verified

356
357
358def interact(banner=None, readfunc=None, local=None, exitmsg=None, local_exit=False):
359 """Closely emulate the interactive Python interpreter.
360
361 This is a backwards compatible interface to the InteractiveConsole
362 class. When readfunc is not specified, it attempts to import the
363 readline module to enable GNU readline if it is available.
364
365 Arguments (all optional, all default to None):
366
367 banner -- passed to InteractiveConsole.interact()
368 readfunc -- if not None, replaces InteractiveConsole.raw_input()
369 local -- passed to InteractiveInterpreter.__init__()
370 exitmsg -- passed to InteractiveConsole.interact()
371 local_exit -- passed to InteractiveConsole.__init__()
372
373 """
374 console = InteractiveConsole(local, local_exit=local_exit)
375 if readfunc is not None:
376 console.raw_input = readfunc
377 else:
378 try:
379 import readline # noqa: F401
380 except ImportError:
381 pass
382 console.interact(banner, exitmsg)
383
384
385if __name__ == "__main__":

Callers 1

code.pyFile · 0.85

Calls 2

interactMethod · 0.95
InteractiveConsoleClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…