Pausing at a Line With node inspect
Joan’s November export has three bad rows, and the Python and JavaScript imports print the same
four lines about them. Line 3 of the export says the amount is not a number, but what did the
amount field actually hold? In Python, you drop breakpoint() into parse_row(), right after the
amount is converted, and run the script as usual:
except ValueError as err:
raise BadRowError(line, donor, "amount is not a number") from err
breakpoint()
if amount <= 0:
You’re at pdb’s prompt, on the breakpoint line, where p and n work as usual:
$ python donations.py november.csv
> /Users/you/donations/donations.py(31)parse_row()
-> breakpoint()
(Pdb) p amount_text
'50.00'
(Pdb) p amount
50.0
(Pdb) n
> /Users/you/donations/donations.py(32)parse_row()
-> if amount <= 0:
(Pdb)