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.
Whenever you want to leave the pdb console, type the command quit or exit . If you would like to explicitly restart a program at any place within the program, you can do so with the command run .
system('clear') , just write space characters in the lines of the screen that you want to clear. Alternatively, just write the new content, with spaces to pad to the end of the line to clear anything that was there before.
You can clear the Python interpreter console screen using a system call. System calls to clear the console: For the window system, cls clear the console. For the Linux system, clear command works.
To start execution, you use the continue or c command. If the program executes successfully, you will be taken back to the (Pdb) prompt where you can restart the execution again. At this point, you can use quit / q or Ctrl+D to exit the debugger.
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
You could always print('\n'*30)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With