June 2017
Beginner
352 pages
8h 39m
English
With compound data structures such as our table of isotypes, it can be helpful to have them printed out in a much more readable form. We can do this with the Python Standard Library pretty-printing module called pprint, which contains a function called pprint:
>>> from pprint import pprint as pp
Note that if we didn't bind the pprint function to a different name pp, the function reference would overwrite the module reference, preventing further access to contents of the module:
>>> pp(m){ 'B': [10, 11], 'Be': [7, 9, 10], 'C': [11, 12, 13, 14], 'H': [1, 2, 3, 4, 5, 6, 7], 'He': [3, 4], 'Li': [6, 7], 'N': [13, 14, 15]}
Gives us a much more comprehensible display.
Let's move on from dictionaries and look at a new built-in data ...
Read now
Unlock full access