June 2017
Beginner
352 pages
8h 39m
English
After you're out of PDB, let's remove the set_trace() call and modify digits() to fix the problem we found:
def digits(x): """Convert an integer into a list of digits. Args: x: The number whose digits we want. Returns: A list of the digits, in order, of ``x``. >>> digits(4586378) [4, 5, 8, 6, 3, 7, 8] """ digs = [] while x != 0: div, mod = divmod(x, 10) digs.append(mod) x = div return digs
If we run our program now, we see that we're passing all tests, and it runs very quickly:
$ python palindrome.py...----------------------------------------------------------------------Ran 3 tests in 0.001sOK
So that's a basic PDB session, and it demonstrates some of the core features of PDB. PDB has many other commands and features, however, ...
Read now
Unlock full access