W WolfCode · CSC 141

Print vs pdb

print 和 pdb

≈ 20 min · python-debugging · Open in WolfCode

Two semantic-error functions. Print debugging finds both. Brief intro to pdb for the day prints stop being enough.

Bug 1 — forgot to divide

Python · runnable

Bug 2 — boundary check

Python · runnable

The fixes

Python · runnable

When print stops being enough — try pdb

In a real script you'd add breakpoint() and run with python (not in browser)