# Example code for [Effective Python LiveLessons](http://www.informit.com/store/effective-python-livelessons-video-training-downloadable-9780134175164)

These items are numbered differently than in the book. Below are links to each item's corresponding piece of example code.

To run all the code for an item, just type ./item_01.py into your shell and see what it prints out. Alternatively you can type python3 item_01.py or python2.7 item_03_example_03.py to run a specific version of Python.

- "[Item 1 Know how to slice sequences](example_code/item_05.py)"
- "[Item 2 Avoid using start, end, and stride in a single slice](example_code/item_05.py)"
- "[Item 3 Prefer enumerate over range](example_code/item_10.py)"
- "[Item 4 Use zip to process iterators in parallel](example_code/item_11.py)"
- "[Item 5 Avoid else blocks after for and while loops](example_code/item_12.py)"
- "[Item 6 Take advantage of each block in try/except/else/finally](example_code/item_13.py)"
- "[Item 7 Consider contextlib and with statements for reusable try/finally behavior](example_code/item_43.py)"
- "[Item 8 Use list comprehensions instead of map and filter](example_code/item_07.py)"
- "[Item 9 Avoid more than two expressions in list comprehensions](example_code/item_08.py)"
- "[Item 10 Consider generator expressions for large comprehensions](example_code/item_09.py)"
- "[Item 11 Consider generators instead of returning lists](example_code/item_16.py)"
- "[Item 12 Be defensive when iterating over arguments ](example_code/item_17.py)"
- "[Item 13 Know how closures interact with variable scope](example_code/item_15.py)" and [example for Python 2](example_code/item_15_example_09.py)
- "[Item 14 Accept functions for simple interfaces instead of classes](example_code/item_23.py)"
- "[Item 15 Reduce visual noise with variable positional arguments](example_code/item_19.py)"
- "[Item 16 Provide optional behavior with keyword arguments](example_code/item_19.py)"
- "[Item 17 Enforce clarity with keyword-only arguments](example_code/item_21.py)"
- "[Item 18 Use None and docstrings to specify dynamic default arguments](example_code/item_20.py)"
- "[Item 19 Prefer helper classes over bookkeeping with dictionaries and tuples](example_code/item_22.py)"
- "[Item 20 Use plain attributes instead of get and set methods ](example_code/item_29.py)"
- "[Item 21 Prefer public attributes over private ones](example_code/item_27.py)"
- "[Item 22 Use @classmethod polymorphism to construct objects generically](example_code/item_24.py)"
- "[Item 23 Use subprocess to manage child processes](example_code/item_36.py)"
- "[Item 24 Use threads for blocking I/O, avoid for parallelism](example_code/item_37.py)"
- "[Item 25 Use Lock to prevent data races in threads](example_code/item_38.py)"
- "[Item 26 Use Queue to coordinate work between threads](example_code/item_39.py)"
- "[Item 27 Consider concurrent.futures for true parallelism](example_code/item_41.py)"
- "Item 28 Use virtual environments for isolated and reproducible dependencies" has no example code
- "[Item 29 Test everything with unittest](example_code/item_56.py) and [a directory of tests](example_code/item_56/testing)"
- "Item 30 Consider interactive debugging with pdb" has no example code
- "[Item 31 Profile before optimizing](example_code/item_58.py)"
- "[Item 32 Use tracemalloc to understand memory usage and leaks](example_code/item_59/tracemalloc)"
