7. Becoming Pythonic
Overview
By the end of this chapter, you will be able to, write succinct, readable expressions for creating lists; use Python comprehensions with lists, dictionaries, and sets; use collections.defaultdict
to avoid exceptions when using dictionaries; write iterators to enable Pythonic access to your own data types; explain how generator functions are related to iterators, and write them in order to defer complex calculations; use the itertools
module to succinctly express complex sequences of data and use the re
module to work with regular expressions in Python.