Oddly enough, both better and worse than Perl debugging – better architected in my opnion, but poorly explained and evangelized – to the point where Python book and article writers say “use print statements” to debug code, instead of the debugger.
From the command-line:
python -m pdb yourcode.py
This will inject the pdb module into your program, and will start debugging at the first line of your program as if a pdb.set_trace() call had been issued before the first line of your code.
From inside your code:
import pdb ... pdb.set_trace()
Importing the pdb module gives you access to the debugger features. set_trace() will set an unconditional breakpoint, dropping you into the interactive debugger prompt. Obviously, this requires a console to exist.
Simple introduction: Debugging in Python.
From the Python Documentation: 26.2. pdb – The Python Debugger.
Another article: Interactive Debugging in Python
A more in-depth article by Doug Hellmann: pdb – Interactive Debugger.
Adding features to pdb: Python pdb (debugger) disp equivalent?
Python Debugger Cheatsheet – one-page PDF