Zero to Py
With Membership
Suggested price

Zero to Py

A Comprehensive Guide to Learning the Python Programming Language

About the Book

This book aims to be a comprehensive guide to learning the Python Programming Language, covering all the essential concepts and topics that a python developer needs to know. This book has been written so to be accessible to readers of all levels, whether you're just starting your journery into programming, or already have some experience with python. Even more advanced users may find some utility from the later chapters.

This book is divided into four parts.

In Part I of this book, we start by introducing you to the basics of Python, building a foundation on the fundamentals as we cover topics such as data types, operators, control flow, functions, and classes.

In Part II of this book, we build upon the foundation established in Part I and dive deeper into more advanced features of the Python programming language. We explore the more advanced features of Python, discussing topics such as generators, the data object model, metaclasses, etc, with the explicit aim to help you write more efficient and elegant code. And finally, we'll look into Python modules and packaging, so we can see how to take your python code and construct libraries which can be shared with the broader python community.

In Part III of this book, we will take a closer look at some of the "batteries included" sections of the Python standard library. These are the modules and packages that are included with every Python installation and provide a wide range of functionality that can be used to solve a variety of problems. We'll explore packages like functools, itertools, dataclasses, etc.

And finally in Part VI we'll dig into mechanisms for profiling and debugging python. Furthermore when we identify specific pain points in our implementation, we'll see how to refactor our projects to use performant C code for a boost in execution speed. We'll also look into how to use C debuggers to run the python interpreter, so we can debug our C extensions.

As a Leanpub publication, one of the benefits the platform provides is frictionless updates. As such, this book will act as a living document, recieving updates with every release of a minor version of Python, for as long as this book is in active release.

About the Author

Michael Green
Michael Green

Michael is currently a core library developer at Crunch Cloud Analytics, a subsidiary of YouGov. His software development experience includes full-stack web application development, data analysis and visualization, and computational modeling/scientific computing. He previous position was as a research assistant at the University of Missouri-Kansas City, where his work in applying machine learning to nanophotonics has been featured and published in several of the top journals for chemistry, physics, and materials science.

Table of Contents

  • Zero to Py: A Comprehensive Guide to Learning the Python Programming Language
    • Introduction
  • Part I: A Whirlwind Tour
    • Chapter 0: System Setup
      • Installing Python Natively
        • Python Versions
        • Windows
        • macOS
        • Linux
        • What’s in a PATH?
      • Setting up your dev environment
      • Running Python
        • A program that runs programs
        • One interpreter, many modes
    • Chapter 1. Fundamental data types
      • But first, variables
      • Primitives and Containers
      • Mutability vs Immutability
      • Introduction to Python’s data types
        • Primitive Types
          • Booleans
          • Integers
          • Floats
          • Complex
          • Strings
          • Bytes
        • Container Types
          • Tuples and Lists
          • Dictionaries
          • Sets
      • Python Objects
        • References to Objects
    • Chapter 2. Operators
      • Arithmetic
      • Assignment
        • Packing operators
      • Comparison
      • Logical
        • What is Truthy?
        • Short-Circuits
        • Logical Assignments
      • Membership
      • Bitwise
      • Identity
    • Chapter 3. Lexical Structure
      • Line Structure
      • Comments
      • Explicit and Implicit Line Joining
      • Indentation
    • Chapter 4. Control Flow
      • if, elif, and else
      • while
        • break
        • continue
      • for
        • What is an Iterable?
      • for/else and break
      • Exception Handling
        • raise from
        • else and finally
      • match
        • type checking
        • guards
        • Or Patterns
        • as
    • Chapter 5. Functions
      • Function Signatures
        • Explicitly positional/key-value
        • Default Values
          • Mutable Types as Default Values
      • Scope
        • Nested Scopes
        • nonlocal and global
      • Closures
      • Anonymous Functions
      • Decorators
    • Chapter 6. Classes
      • data types as classes.
      • __dunder__ methods
        • The __init__ method
      • Attributes
      • Class Attributes
      • A Functional Approach
      • @staticmethod
      • @classmethod
  • Part II. A Deeper Dive
    • Chapter 7. Expressions, Comprehensions, and Generators
      • Generator Expressions
      • Generator Functions
        • yield from
      • List Comprehensions
      • Dictionary Comprehensions
      • Expressions and the Walrus Operator
    • Chapter 8. Python’s Built-in Functions
      • Type Conversions
      • Mathematical Functions
      • all() and any()
      • dir()
      • enumerate()
      • eval() and exec()
      • map()
      • filter()
      • input() and print()
      • open()
      • range()
      • sorted()
      • reversed()
      • zip()
    • Chapter 9. The Python Data Model
      • Object Creation Using __new__ and __init__
        • Singletons
      • Rich Comparisons
      • Operator Overloading
        • String Representations
      • Emulating Containers
      • Emulating Functions
      • Using Slots
      • Customizing Attribute Access
      • Iterators
        • Lazy Evaluation
      • Context Managers
      • Descriptors
    • Chapter 10. Concepts in Object-Oriented Programming
      • Inheritance
        • Calling the Super Class using super()
        • Multiple Inheritance and Method Resolution Order
      • Encapsulation
      • Polymorphism
    • Chapter 11. Metaclasses
    • Chapter 12. The Data Types, Revisited.
      • Numbers
      • Integers
        • Bits and Bytes
      • Floats
        • Float Methods
        • Hex Values
      • Complex Numbers
      • Strings
        • Split and Join
        • Search and Replace
        • Paddings
        • Formatting
        • Translating
        • Partitioning
        • Prefixes and Suffixes
        • Boolean Checks
        • Case Methods
        • Encodings
      • Bytes
        • Decoding
        • Hex Values
      • Tuples
      • Lists
        • Counting and Indexing
        • Copying
        • Mutations
        • Orderings
      • Dictionaries
        • Iter Methods
        • Getter/Setter Methods
        • Mutations
        • Creating new Dictionaries
      • Sets
        • Mutations
        • Set Theory
        • Boolean Checks
        • Copying
    • Chapter 13. Type Hints
      • Incorporating Type Hints
      • Union types
      • Optional
        • type|None
      • Literal
      • Final
      • Type aliases
      • NewType
      • Generic Types
      • Protocols
        • Runtime type checking
      • TypedDict
    • Chapter 14. Modules, Packages, and Namespaces
      • Modules
        • Module Attributes
        • if __name__ == "__main__":
      • Packages
        • Imports within packages
        • Installation
  • Part III. The Python Standard Library
    • Chapter 15. Virtual Environments
    • Chapter 16. Copy
    • Chapter 17. Itertools
      • Chaining Iterables
      • Filtering Iterables
      • Cycling Through Iterables
      • Creating Groups
      • Slicing Iterables
      • Zip Longest
    • Chapter 18. Functools
      • Partials
      • Reduce
        • Pipes
      • Caching
      • Dispatching
    • Chapter 19. Enums, NamedTuples, and Dataclasses
      • Enums
      • NamedTuples
      • Dataclasses
    • Chapter 20. Multithreading and Multiprocessing
      • Multithreading
        • Thread Locks
      • Multiprocessing
        • Process and Pool
        • Process Locks
        • Pipes and Queues
      • concurrent.futures
    • Chapter 21. Asyncio
      • Coroutines
      • Tasks and Task Groups
        • ExceptionGroup and Exception unpacking
  • Part VI. The Underbelly of the Snake
    • Chapter 22. Debugging
      • pdb
      • Other Debuggers
    • Chapter 23. Profiling
      • cProfile
        • flameprof
        • snakeviz
      • memory_profiler
    • Chapter 24. C extensions
      • Hello World
        • hello_world.c
      • Passing data in and out of Python
        • Memory Management
      • Parsing Arguments
        • Parsing Tuple Arguments
        • Parsing Keyword Arguments
      • Creating PyObjects
      • Importing Modules
      • Defining New Types
      • Stack type
      • Debugging C extensions

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...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

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

In fact, authors have earnedover $13 millionwriting, 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