Michael Driscoll · leanpub.com

About the Technical Reviewers

  1. Ethan Furman
  2. Martin Breuss

Acknowledgments

Introduction

  1. Part I - The Basics
  2. Part II - Intermediate Materials
  3. Part III - Tutorials
  4. Part IV - Python Packaging and Distribution
  5. Target Audience
  6. About the Author
  7. Conventions
  8. Requirements
  9. Book Source Code
  10. Reader Feedback
  11. Errata

Part I - The Python Language

Chapter 1 - Installing Python

  1. Installing on Windows
  2. Installing on Mac
  3. Installing on Linux
  4. Android / iOS
  5. Other Operating Systems
  6. Other Python Variants
  7. Wrapping Up

Chapter 2 - Python Editors

  1. What About the REPL?
  2. Getting Started with IDLE
  3. Getting Started with PyCharm Community Edition
  4. Getting Started with Wing Personal
  5. Getting Started with Visual Studio Code
  6. Wrapping Up

Chapter 3 - Documenting Your Code

  1. What are Comments?
  2. Commenting Out
  3. Multiline Comments
  4. Learning About docstrings
  5. Python’s Style Guide: PEP8
  6. Tools that can help
  7. Wrapping Up
  8. Review Questions

Chapter 4 - Working with Strings

  1. Creating Strings
  2. String Methods
  3. String Formatting
  4. Formatting Strings Using %s (printf-style)
  5. Formatting Strings Using .format()
  6. Formatting Strings with f-strings
  7. String Concatenation
  8. String Slicing
  9. Wrapping Up
  10. Review Questions

Chapter 5 - Numeric Types

  1. Integers
  2. Floats
  3. Complex Numbers
  4. Numeric Operations
  5. Augmented Assignment
  6. Wrapping Up
  7. Review Questions

Chapter 6 - Learning About Lists

  1. Creating Lists
  2. List Methods
  3. List Slicing
  4. Copying a List
  5. Wrapping Up
  6. Review Questions

Chapter 7 - Learning About Tuples

  1. Creating Tuples
  2. Working With Tuples
  3. Concatenating Tuples
  4. Special Case Tuples
  5. Wrapping Up
  6. Review Questions

Chapter 8 - Learning About Dictionaries

  1. Creating Dictionaries
  2. Accessing Dictionaries
  3. Dictionary Methods
  4. Modifying Your Dictionary
  5. Deleting Items From Your Dictionary
  6. Wrapping Up
  7. Review Questions

Chapter 9 - Learning About Sets

  1. Creating a Set
  2. Accessing Set Members
  3. Changing Items
  4. Adding Items
  5. Removing Items
  6. Clearing or Deleting a Set
  7. Set Operations
  8. Wrapping Up
  9. Review Questions

Chapter 10 - Boolean Operations and None

  1. The bool() Function
  2. What About None?
  3. Wrapping Up
  4. Review Questions

Chapter 11 - Conditional Statements

  1. Comparison Operators
  2. Creating a Simple Conditional

Indentation Matters in Python

  1. Branching Conditional Statements
  2. Nesting Conditionals
  3. Logical Operators
  4. Special Operators
  5. Wrapping Up
  6. Review Questions

Chapter 12 - Learning About Loops

  1. Creating a for Loop
  2. Looping Over a String
  3. Looping Over a Dictionary
  4. Extracting Multiple Values in a Tuple While Looping
  5. Using enumerate with Loops
  6. Creating a while Loop
  7. Breaking Out of a Loop
  8. Using continue
  9. Loops and the else Statement
  10. Nesting Loops
  11. Wrapping Up
  12. Review Questions

Chapter 13 - Python Comprehensions

  1. List Comprehensions
  2. Nested List Comprehensions
  3. Dictionary Comprehensions
  4. Set Comprehensions
  5. Wrapping Up
  6. Review Questions

Chapter 14 - Exception Handling

  1. The Most Common Exceptions
  2. Handling Exceptions
  3. Raising Exceptions
  4. Examining the Exception Object
  5. Using the finally Statement
  6. Using the else Statement
  7. Wrapping Up
  8. Review Questions

Chapter 15 - Working with Files

  1. The open() Function
  2. Reading Files
  3. Reading Binary Files
  4. Writing Files
  5. Seeking Within a File
  6. Appending to Files
  7. Catching File Exceptions
  8. Wrapping Up
  9. Review Questions

Chapter 16 - Importing

  1. Using import
  2. Using from to Import Specific Bits & Pieces
  3. Using as to assign a new name
  4. Importing Everything
  5. Wrapping Up
  6. Review Questions

Chapter 17 - Functions

  1. Creating a Function
  2. Calling a Function
  3. Passing Arguments
  4. Type Hinting Your Arguments
  5. Passing Keyword Arguments
  6. Required and Default Arguments
  7. What are *args and **kwargs?
  8. Positional-only Parameters
  9. Scope
  10. Wrapping Up
  11. Review Questions

Chapter 18 - Classes

  1. Class Creation
  2. Figuring Out self
  3. Public and Private Methods / Attributes
  4. Subclass Creation
  5. Polymorphism
  6. Making the Class Nicer
  7. Wrapping Up
  8. Review Questions

Part II - Beyond the Basics

Chapter 19 - Introspection

  1. Using the type() Function
  2. Using the dir() Function
  3. Getting help()
  4. Other Built-in Introspection Tools
  5. Wrapping Up
  6. Review Questions

Chapter 20 - Installing Packages with pip

  1. Installing a Package

What is the “Path”?

  1. Exploring Command Line Options
  2. Installing with requirements.txt
  3. Upgrading a Package
  4. Checking What’s Installed

Packages Not Installed with pip

  1. Uninstalling Packages
  2. Alternatives to pip
  3. Wrapping Up
  4. Review Questions

Chapter 21 - Python Virtual Environments

  1. Python’s venv Library
  2. The virtualenv Package
  3. Other Tools
  4. Wrapping Up
  5. Review Questions

Chapter 22 - Type Checking in Python

  1. Pros and Cons of Type Hinting
  2. Built-in Type Hinting / Variable Annotation
  3. Collection Type Hinting
  4. Hinting Values That Could be None
  5. Type Hinting Functions
  6. What To Do When Things Get Complicated
  7. Classes
  8. Decorators
  9. Aliasing
  10. Other Type Hints
  11. Type Comments
  12. Static Type Checking
  13. Wrapping Up
  14. Review Questions

Chapter 23 - Creating Multiple Threads

  1. Pros of Using Threads
  2. Cons of Using Threads
  3. Creating Threads
  4. Subclassing Thread
  5. Writing Multiple Files with Threads
  6. Wrapping Up
  7. Review Questions

Chapter 24 - Creating Multiple Processes

  1. Pros of Using Processes
  2. Cons of Using Processes
  3. Creating Processes with multiprocessing
  4. Subclassing Process
  5. Creating a Process Pool
  6. Wrapping Up
  7. Review Questions

Chapter 25 - Launching Subprocesses with Python

  1. The subprocess.run() Function
  2. The subprocess.Popen() Class

What is SIGKILL / SIGTERM?

  1. The subprocess.Popen.communicate() Function
  2. Reading and Writing with stdin and stdout
  3. Wrapping Up
  4. Review Questions

Chapter 26 - Debugging Your Code with pdb

  1. Starting pdb in the REPL
  2. Starting pdb on the Command Line
  3. Stepping Through Code
  4. Adding Breakpoints in pdb
  5. Creating a Breakpoint with set_trace()
  6. Using the built-in breakpoint() Function
  7. Getting Help
  8. Wrapping Up
  9. Review Questions

Chapter 27 - Learning About Decorators

  1. Creating a Function
  2. Creating a Decorator
  3. Applying a Decorator with @
  4. Creating a Decorator for Logging
  5. Stacking Decorators
  6. Passing Arguments to Decorators
  7. Using a Class as a Decorator
  8. Python’s Built-in Decorators
  9. Python Properties
  10. Wrapping Up
  11. Review Questions

Chapter 28 - Assignment Expressions

  1. Using Assignment Expressions
  2. What You Cannot Do With Assignment Expressions
  3. Wrapping Up
  4. Review Questions

Chapter 29 - Profiling Your Code

  1. Learning How to Profile with cProfile
  2. Profiling a Python Script with cProfile
  3. Working with Profile Data Using pstats
  4. Other Profilers
  5. Wrapping Up
  6. Review Questions

Chapter 30 - An Introduction to Testing

  1. Using doctest in the Terminal
  2. Using doctest in Your Code
  3. Using doctest From a Separate File
  4. Using unittest For Test Driven Development
  5. Wrapping Up
  6. Review Questions

Chapter 31 - Learning About the Jupyter Notebook

  1. Installing The Jupyter Notebook
  2. Creating a Notebook
  3. Adding Content
  4. Adding an Extension
  5. Exporting Notebooks to Other Formats
  6. Wrapping Up
  7. Review Questions

Part III - Practical Python

Chapter 32 - How to Create a Command-line Application with argparse

  1. Parsing Arguments
  2. Creating Helpful Messages
  3. Adding Aliases
  4. Using Mutually Exclusive Arguments
  5. Creating a Simple Search Utility
  6. Wrapping Up
  7. Review Questions

Chapter 33 - How to Parse XML

  1. Parsing XML with ElementTree
  2. Creating XML with ElementTree
  3. Editing XML with ElementTree
  4. Manipulating XML with lxml
  5. Wrapping Up
  6. Review Questions

Chapter 34 - How to Parse JSON

  1. Encoding a JSON String
  2. Saving JSON to Disk
  3. Decoding a JSON String
  4. Loading JSON from Disk
  5. Validating JSON with json.tool
  6. Wrapping Up
  7. Review Questions

Chapter 35 - How to Scrape a Website

  1. Rules for Web Scraping
  2. Preparing to Scrape a Website
  3. Scraping a Website
  4. Downloading a File
  5. Wrapping Up
  6. Review Questions

Chapter 36 - How to Work with CSV files

  1. Reading a CSV File
  2. Reading a CSV File with DictReader
  3. Writing a CSV File
  4. Writing a CSV File with DictWriter
  5. Wrapping Up
  6. Review Questions

Chapter 37 - How to Work with a Database Using sqlite3

  1. Creating a SQLite Database
  2. Adding Data to Your Database
  3. Searching Your Database
  4. Editing Data in Your Database
  5. Deleting Data From Your Database
  6. Wrapping Up
  7. Review Questions

Chapter 38 - Working with an Excel Document in Python

  1. Python Excel Packages
  2. Getting Sheets from a Workbook
  3. Reading Cell Data
  4. Iterating Over Rows and Columns
  5. Writing Excel Spreadsheets
  6. Adding and Removing Sheets
  7. Adding and Deleting Rows and Columns
  8. Wrapping Up
  9. Review Questions

Chapter 39 - How to Generate a PDF

  1. Installing ReportLab
  2. Creating a Simple PDF with the Canvas
  3. Creating Drawings and Adding Images Using the Canvas
  4. Creating Multi-page Documents with PLATYPUS
  5. Creating a Table
  6. Wrapping Up
  7. Review Questions

Chapter 40 - How to Create Graphs

  1. Installing Matplotlib
  2. Creating a Simple Line Chart with PyPlot
  3. Creating a Bar Chart
  4. Creating a Pie Chart
  5. Adding Labels
  6. Adding Titles to Plots
  7. Creating a Legend
  8. Showing Multiple Figures
  9. Wrapping Up
  10. Review Questions

Chapter 41 - How to Work with Images in Python

  1. Installing Pillow
  2. Opening Images
  3. Cropping Images
  4. Using Filters
  5. Adding Borders
  6. Resizing Images
  7. Wrapping Up
  8. Review Questions

Chapter 42 - How to Create a Graphical User Interface

  1. Installing wxPython
  2. Learning About Event Loops
  3. How to Create Widgets
  4. How to Lay Out Your Application
  5. How to Add Events
  6. How to Create an Application
  7. Wrapping Up
  8. Review Questions

Part IV - Distributing Your Code

Chapter 43 - How to Create a Python Package

  1. Creating a Module
  2. Creating a Package
  3. Packaging a Project for PyPI
  4. Creating Project Files
  5. Creating setup.py
  6. Generating a Python Wheel
  7. Uploading to PyPI
  8. Wrapping Up
  9. Review Questions

Chapter 44 - How to Create an Exe for Windows

  1. Installing PyInstaller
  2. Creating an Executable for a Command-Line Application
  3. Creating an Executable for a GUI
  4. Wrapping Up
  5. Review Questions

Chapter 45 - How to Create an Installer for Windows

  1. Installing Inno Setup
  2. Creating an Installer
  3. Testing Your Installer
  4. Wrapping Up
  5. Review Questions

Chapter 46 - How to Create an “exe” for Mac

  1. Installing PyInstaller
  2. Creating an Executable with PyInstaller
  3. Wrapping Up
  4. Review Questions

Afterword

Appendix A - Version Control

  1. Version Control Systems
  2. Distributed vs Centralized Versioning
  3. Common Terminology
  4. Python IDE Version Control Support
  5. Wrapping Up

Appendix B - Version Control with Git

  1. Installing Git
  2. Configuring Git
  3. Creating a Project
  4. Ignoring Files
  5. Initializing a Repository
  6. Checking the Project Status
  7. Adding Files to a Repository
  8. Committing Files
  9. Viewing the Log
  10. Changing a File
  11. Reverting a File
  12. Checking Out Previous Commits
  13. Pushing to Github
  14. Wrapping Up

Review Question Answer Key

  1. Chapter 3 - Documenting Your Code
  2. Chapter 4 - Working with Strings
  3. Chapter 5 - Numeric Types
  4. Chapter 6 - Learning About Lists
  5. Chapter 7 - Learning About Tuples
  6. Chapter 8 - Learning About Dictionaries
  7. Chapter 9 - Learning About Sets
  8. Chapter 10 - Boolean Operations and None
  9. Chapter 11 - Conditional Statements
  10. Chapter 12 - Learning About Loops
  11. Chapter 13 - Python Comprehensions
  12. Chapter 14 - Exception Handling
  13. Chapter 15 - Working with Files
  14. Chapter 16 - Importing
  15. Chapter 17 - Functions
  16. Chapter 18 - Classes
  17. Chapter 19 - Introspection
  18. Chapter 20 - Installing Packages with pip
  19. Chapter 21 - Python Virtual Environments
  20. Chapter 22 - Type Checking in Python
  21. Chapter 23 - Creating Multiple Threads
  22. Chapter 24 - Creating Multiple Processes
  23. Chapter 25 - Launching Subprocesses with Python
  24. Chapter 26 - Debugging Your Code
  25. Chapter 27 - Learning About Decorators
  26. Chapter 28 - Assignment Expressions
  27. Chapter 29 - Profiling Your Code
  28. Chapter 30 - An Introduction to Testing
  29. Chapter 31 - Learning About the Jupyter Notebook
  30. Chapter 32 - How to Create a Command Line Application with argparse
  31. Chapter 33 - How to Parse XML
  32. Chapter 34 - How to Parse JSON
  33. Chapter 35 - How to Scrape a Website
  34. Chapter 36 - How to Work with CSV files
  35. Chapter 37 - How to Work with a Database Using sqlite
  36. Chapter 38 - Working with an Excel Document in Python
  37. Chapter 39 - How to Generate a PDF
  38. Chapter 40 - How to Create Graphs
  39. Chapter 41 - How to Work with Images in Python
  40. Chapter 42 - How to Create a Graphical User Interface
  41. Chapter 43 - How to Create a Python Package
  42. Chapter 44 - How to Create an Exe for Windows
  43. Chapter 45 - How to Create an Installer for Windows
  44. Chapter 46 - How to Create an “exe” for Mac

Read the original on leanpub.com ↗