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)
| 356 | |
| 357 | |
| 358 | def 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 | |
| 385 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…