Leanpub Header

Skip to main content

Python 201

Intermediate Python

Python 201 is the sequel to my first book, Python 101. If you already know the basics of Python and now you want to go to the next level, then this is the book for you! This book is for intermediate level Python programmers only. There won't be any beginner chapters here. This book is based on  Python 3.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
20,410
Readers
258
Pages
61,206Words
About

About

About the Book

Python 201 is the sequel to my first book, Python 101. If you already know the basics of Python and now you want to go to the next level, then this is the book for you! This book is for intermediate level Python programmers only. There won't be any beginner chapters here. This book is based on Python 3.

The book will be broken up into five parts. Here's how:

Part I - Intermediate Modules

Chapter 1 - The argparse module

Chapter 2 - The collections module

Chapter 3 - The contextlib module (Context Managers)

Chapter 4 - The functools module (Function overloading, caching, etc)

Chapter 5 - All about imports

Chapter 6 - The importlib module

Chapter 7 - The itertools module

Chapter 8 - The re module (An Intro to Regex in Python)

Chapter 9 - The typing module (Type Hinting)

Part II - Odds and Ends

Chapter 10 - generators / iterators

Chapter 11 - map, filter, reduce

Chapter 12 - unicode

Chapter 13 - benchmarking

Chapter 14 - encryption

Chapter 15 - Connecting to databases

Chapter 16 - super

Chapter 17 - descriptors (magic methods)

Chapter 18 - Scope (local, global and the new non_local)

Part III - Web

Chapter 19 - Web scraping

Chapter 20 - Working with web APIs

Chapter 21 - ftplib

Chapter 22 - urllib

Part IV - Testing

Chapter 23 - Doctest

Chapter 24 - unittest

Chapter 25 - mock

Chapter 26 - coverage.py

Part V - Concurrency

Chapter 27 - The asyncio module

Chapter 28 - The threading module

Chapter 29 - The multiprocessing module

Chapter 30 - The concurrent.futures module

Share this book

Categories

Price

Pick Your Price...

Minimum price

$19.99

$24.99

You pay

$24.99

Author earns

$19.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Michael Driscoll

Michael has been programming with Python since 2006. He is the author of the popular Python blog, The Mouse Vs. the Python. Michael has been a technical reviewer for Packt Publishing and No Starch Press.  He is also a contributor on Real Python.

He also co-authored The Essential Core Python Cheat Sheet for DZone.

Michael released his first book, Python 101, June 3rd, 2014. He wrote the follow up, Python 201: Intermediate Python and published it in the summer of 2016. He is also the author of wxPython Cookbook from Apress as well as Python Interviews from Packt Publishing.

Michael is currently working on some new books as well.

Leanpub Podcast

Episode 47

An Interview with Michael Driscoll

Contents

Table of Contents

Introduction

  1. About the Author
  2. Conventions
  3. Requirements
  4. Reader Feedback
  5. Errata
  6. Code Examples
  7. Part I - The Intermediate Modules
  8. Chapter 1 - An Intro to Argument Parsing using argparse
  9. Getting Started
  10. Adding Arguments
  11. Short Options and Long Options
  12. Options that Conflict
  13. Wrapping Up
  14. Chapter 2 - The collections module
  15. ChainMap
  16. Counter
  17. defaultdict
  18. deque
  19. namedtuple
  20. OrderedDict
  21. Wrapping Up
  22. Chapter 3 - Context Managers
  23. Creating a Context Manager class
  24. Creating a Context Manager using contextlib
  25. contextlib.closing(thing)
  26. contextlib.suppress(*exceptions)
  27. contextlib.redirect_stdout / redirect_stderr
  28. ExitStack
  29. Reentrant Context Managers
  30. Wrapping Up
  31. Chapter 4 - The functools module
  32. Caching with functools.lru_cache
  33. functool.partial
  34. Function Overloading with functools.singledispatch
  35. functools.wraps
  36. Wraps to the Rescue!
  37. Wrapping Up
  38. Chapter 5 - All About Imports
  39. Regular Imports
  40. Using “from module import something”
  41. Relative Imports
  42. Optional Imports
  43. Local Imports
  44. Import Pitfalls
  45. Wrapping Up
  46. Chapter 6 - The importlib Module
  47. Dynamic Imports
  48. Module Import Checking
  49. Import From Source File
  50. import_from_github_com
  51. Wrapping Up
  52. Chapter 7 - Iterators and Generators
  53. Iterators
  54. Creating Your Own Iterators
  55. Generators
  56. Wrapping Up
  57. Chapter 8 - The itertools Module
  58. The Infinite Iterators
  59. Iterators That Terminate
  60. The Combinatoric Generators
  61. Wrapping Up
  62. Chapter 9 - Regular Expressions
  63. The Matching Characters
  64. Pattern Matching Using search
  65. Escape Codes
  66. Compiling
  67. Compilation Flags
  68. Finding Multiple Instances
  69. Backslashes Are Complicated
  70. Wrapping Up
  71. Chapter 10 - The typing Module
  72. Type Hints and Overloaded Functions
  73. Wrapping Up
  74. Part II - Odds and Ends
  75. Chapter 11 - Python Built-ins
  76. any
  77. enumerate
  78. eval
  79. filter
  80. map
  81. zip
  82. Wrapping Up
  83. Chapter 12 - Unicode
  84. Encoding / Decoding
  85. Wrapping Up
  86. Chapter 13 - Benchmarking
  87. timeit
  88. Importing timeit for Testing
  89. Use a decorator
  90. Create a Timing Context Manager
  91. cProfile
  92. line_profiler
  93. memory_profiler
  94. profilehooks
  95. Wrapping Up
  96. Chapter 14 - Encryption and Cryptography
  97. Hashing
  98. Key Derivation
  99. PyCrypto
  100. The cryptography Package
  101. Wrapping Up
  102. Chapter 15 - Databases
  103. Basic SQL Syntax
  104. adodbapi
  105. pyodbc
  106. pypyodbc
  107. MySQL
  108. PostgreSQL
  109. Object Relational Mappers
  110. Wrapping Up
  111. Chapter 16 - The super built-in
  112. Python 2 vs Python 3
  113. Method Resolution Order (MRO)
  114. Wrapping Up
  115. Chapter 17 - Descriptors
  116. The Descriptor Protocol
  117. Calling a Descriptor
  118. Descriptor Examples
  119. Wrapping Up
  120. Chapter 18 - Scope
  121. Local Scope
  122. Global Scope
  123. nonlocal Scope
  124. Wrapping Up
  125. Part III - Working with the Web
  126. Chapter 19 - Web Scraping
  127. Tips for Scraping
  128. Preparing to Scrape
  129. BeautifulSoup
  130. Scrapy
  131. Wrapping Up
  132. Chapter 20 - Web APIs
  133. Twitter
  134. Reddit
  135. Wikipedia
  136. Other API Libraries
  137. Wrapping Up
  138. Chapter 21 - Working with FTP
  139. Connecting to an FTP Server
  140. Navigating Directories with ftplib
  141. Downloading a File via FTP
  142. Uploading Files to an FTP Server
  143. Wrapping Up
  144. Chapter 22 - The urllib Module
  145. urllib.request
  146. urllib.parse
  147. urllib.robotparser
  148. Wrapping Up
  149. Part IV - Testing
  150. Chapter 24 - The doctest Module
  151. How it Works
  152. Check Your Test With a Text File
  153. Option Flags and Directives
  154. Wrapping Up
  155. Chapter 24 - The unittest Module
  156. A Simple Example
  157. Command-Line Interface
  158. Creating a More Complex Test
  159. Creating Test Suites
  160. How to Skip Tests
  161. Integrating with doctest
  162. Wrapping Up
  163. Chapter 25 - The mock Module
  164. Simple Examples
  165. Side Effects
  166. Autospeccing
  167. The Patch
  168. Wrapping Up
  169. Chapter 26 - An Intro to coverage.py
  170. Additional Information
  171. Wrapping Up
  172. Part V - Concurrency
  173. Chapter 27 - The asyncio Module
  174. Definitions
  175. async and await
  176. A Bad Coroutine Example
  177. A Better Coroutine Example
  178. Scheduling Calls
  179. Tasks
  180. Wrapping Up
  181. Chapter 28 - The threading Module
  182. Intro to threads
  183. Locks and Synchronization
  184. Timers
  185. Other Thread Components
  186. Thread Communication
  187. Wrapping Up
  188. Chapter 29 - The multiprocessing Module
  189. Getting Started With Multiprocessing
  190. Locks
  191. Logging
  192. The Pool Class
  193. Process Communication
  194. Wrapping Up
  195. Chapter 30 - The concurrent.futures Module
  196. Creating a Pool
  197. Deadlocks
  198. Wrapping Up

Contributor

About the Contributors

Varya Kolesnikova

Varya Kolesnikova is a talented illustrator from St. Petersburg, Russia. Varya did the cover art for the book, Python 201: Intermediate Python by Michael Driscoll. You can see some of her other art on her Behance profile page

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub