gwg gwg - 23 days ago 6x
Python Question

How can I clear the Python pdb screen?

Let's say I write

(Pdb) p dir(object)

and, now my screen is taken up with a list of attributes. How can I clear this text while still in debug mode? Importantly, I don't want to lose my place in the code.


Depends on your OS. If you're on windows this should work:

import os; os.system('cls')

If you're on GNU/Linux (I think in Mac OS too) this should do the trick:

import os; os.system('clear')

But, if you use bash as you shell interpreter, there is a handy keymap: CTRL+l