Skip to content
Advertisement

Tag: console

Enabling console features with code.interact

If I start a new Python interactive session from the command line, some console features such as using the arrow keys to access a previous command, etc. are present. If instead, however, I use code.interact() to start an interactive session from inside a larger script, the escape sequences aren’t properly handled – e.g. pressing the ⮹ key prints ^[[A instead

How to clear the interpreter console?

Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I’m wondering if, and how, to clear the

Advertisement