pyguides

Guides

Guides

In-depth guides for Python developers.

  1. Rich Terminal Output in Python

    Add colored, formatted terminal output to Python CLIs with the Rich library. Covers markup, tables, progress bars, and status spinners.

  2. argparse Basics: Parsing Command-Line Arguments in Python

    Learn argparse basics in Python. Build command-line interfaces with positional and optional arguments, type conversion, default values, and help messages.

  3. NumPy Basics: Arrays and Vectorized Math

    Learn to create and manipulate NumPy arrays, perform vectorized math operations, and use broadcasting to write faster, cleaner numerical code.

  4. email module

    Parse, compose, and encode email messages in Python. Work with Message objects, MIME structures, headers, and encoding for plain-text and multipart emails.

  5. ftplib module

    Connect to FTP servers, upload and download files, navigate directories, and manage FTP connections using Python's built-in ftplib library.

  6. Build a CSV Data Analyzer

    Learn to read, filter, aggregate, and write CSV data in Python using the standard library csv module — no third-party dependencies required.

  7. Build a Markdown to HTML Converter in Python

    Learn how to convert Markdown to HTML in Python using mistune and markdown, add syntax highlighting with Pygments, and sanitize output to prevent XSS attacks.

  8. Build a Text Adventure Game

    Create an interactive fiction game in Python using dictionaries, loops, and input handling. A step-by-step guide for beginners.

  9. Python Number Guessing Game — Your First Beginner Project

    Learn Python by building an interactive number guessing game. Covers variables, conditionals, loops, try/except, random.randint(), input(), and int().

  10. Build a CLI task tracker app in Python

    Build a command-line task tracker in Python using argparse and JSON persistence. Subcommands, argument parsing, and disk storage explained.

  11. Build a File Organizer Script

    Learn how to write a Python script that automatically organizes files by extension, pattern, or date using pathlib, shutil, and glob.

  12. Build a Password Generator in Python

    Learn to generate cryptographically secure passwords and memorable passphrases using Python's secrets module with clear examples.

  13. Modern Python Workflow with Rye and uv

    Learn how uv replaces pip, venv, and more for fast Python project and package management, and what to do with an existing Rye project.

  14. Watching File Changes with watchfiles

    A practical guide to monitoring file system changes with Python's watchfiles library — covering the full API, filters, debouncing, and hot reloading workflows.

  15. Running Python Apps with Granian

    Learn how to use Granian, a Rust-based HTTP server for Python ASGI, RSGI, and WSGI applications with native HTTP/2 and WebSocket support.

  16. Result Types and Error Handling Without Exceptions

    Learn how to handle errors in Python using Result types — a functional programming pattern inspired by Rust that avoids exceptions.

  17. SQLModel: SQLAlchemy Meets Pydantic

    Learn how SQLModel unifies SQLAlchemy ORM and Pydantic validation in a single Python model class, with easy FastAPI integration.

  18. How to Check if a String is a Number in Python

    Learn multiple ways to check if a string contains a number in Python. Includes examples for integers, floats, and handling edge cases.

  19. Distributed Computing with Dask

    Learn how to scale your Python computations across multiple machines using Dask's distributed computing capabilities.

  20. Fast Serialisation with msgspec

    Learn how msgspec provides high-performance serialization with zero-copy decoding and built-in validation for Python applications.

  21. Getting Started with Polars

    A practical guide to Polars, the fast DataFrame library for Python. Learn to create DataFrames, run queries, and use lazy execution.

  22. Building terminal UIs with Textual in Python

    Build rich terminal user interfaces in Python with the Textual framework. Covers widgets, layouts, CSS styling, events, and a practical task tracker example.

  23. attrs vs dataclasses: A Practical Comparison

    Compare Python attrs and dataclasses side-by-side—understand when to use the stdlib option versus the third-party library with more features.

  24. Runtime Type Checking with beartype

    Add runtime type safety to your Python functions with beartype—the fast, decorator-based type checker that catches type errors before they reach production.

  25. Advanced Structural Pattern Matching

    Go beyond match/case basics. Explore mapping patterns, nested structures, custom classes, and state machines.

  26. Base64 Encoding and Decoding in Python

    Learn how to encode and decode Base64 data in Python using the base64 module, with practical examples.

  27. Building CLIs with Click

    Learn how to create command-line interfaces in Python using Click, a composable and ergonomic library.

  28. Context Variables with contextvars

    Learn how to use contextvars for thread-local and task-local state in async Python. Covers ContextVar, copy_context(), and practical patterns.

  29. Dynamic Imports with importlib

    Learn to dynamically import modules and access attributes at runtime using Python's importlib.

  30. Message Authentication with hmac

    Learn how to use Python's hmac module to create and verify keyed-hash message authentication codes (HMAC) for data integrity and authentication.

  31. ProcessPoolExecutor and Pool in Python

    Learn how to use ProcessPoolExecutor and Pool to parallelize CPU-bound tasks. Covers pool management, mapping, and common patterns.

  32. Thread-Safe Queues with queue.Queue

    Learn how to use Python queue.Queue for thread-safe communication between threads. Covers FIFO, LIFO, and priority queues with practical examples.

  33. Python Security Best Practices

    Protect your Python apps from common vulnerabilities. Learn input validation, secure data handling, authentication, and defense-in-depth strategies.

  34. SSL/TLS Connections with the ssl Module

    Learn how to use Python's ssl module to create secure network connections, verify certificates, and configure TLS contexts for production use.

  35. Trio vs asyncio: Structured Concurrency in Python

    Compare Trio and asyncio for async Python. Learn when structured concurrency matters and which library fits your project.

  36. Processing CSV Files in Python

    Learn how to read, write, and process CSV files in Python using the csv module and pandas.

  37. Building APIs with FastAPI

    Learn how to create REST APIs quickly with FastAPI, from basic endpoints to parameterized routes and data validation with Pydantic.

  38. Making HTTP Requests with httpx

    Learn how to make HTTP requests in Python using httpx—a modern library supporting both sync and async APIs, HTTP/2, and a requests-compatible interface.

  39. Subplots and Layouts in Matplotlib

    Learn how to create multiple plots in a single figure using subplots, gridspec, and layout engines.

  40. pandas DataFrames Explained

    Master pandas DataFrames: creation, indexing, manipulation, and analysis of tabular data in Python.

  41. NumPy Arrays: The Complete Guide

    Master NumPy arrays: creation, indexing, slicing, and operations for efficient numerical computing.

  42. pandas groupby: Split, Apply, Combine

    Master pandas groupby operations to split data into groups, apply functions, and combine results for powerful data analysis.

  43. Profiling and Optimizing Python Code

    Learn how to identify performance bottlenecks in your Python code using profilers, and apply proven optimization techniques to make your programs run faster.

  44. Understanding pyproject.toml

    Learn how to configure Python projects using pyproject.toml, the modern standard for project metadata.

  45. Data Validation with Pydantic in Python

    Learn how to use Pydantic to validate data, define schemas, and create robust data models in your Python applications.

  46. Abstract Base Classes in Depth

    Master Python ABCs—explore advanced patterns like abstract properties, classmethods, virtual subclasses, and when to choose ABCs over Protocols.

  47. Understanding Python Bytecode

    Learn what Python bytecode is, how the interpreter compiles your code, and how to inspect and optimize by understanding what happens under the hood.

  48. csv.DictReader and csv.DictWriter

    Learn how to read and write CSV files using dictionaries with Python's csv.DictReader and csv.DictWriter classes.

  49. Customising pickle with copyreg

    Learn how to use Python's copyreg module to register custom picklers and reducers for classes, making them serializable with pickle.

  50. Managing Config with python-dotenv

    Learn how to use python-dotenv to manage environment variables in Python, keeping your configuration separate from your code.

  51. The GIL Explained

    Understand Python Global Interpreter Lock (GIL), why it exists, and how to work around its limitations for true parallelism.

  52. Hashing with hashlib

    Learn how to use Python's hashlib module to compute cryptographic hashes, checksums, and digests for data integrity and security.

  53. Working with IP Addresses in Python

    Learn how to create, validate, and manipulate IPv4 and IPv6 addresses using Python built-in ipaddress module.

  54. Python's Memory Model and Reference Counting

    Understand how Python manages memory internally—explore reference counting, the garbage collector, and how to write memory-efficient code.

  55. Properties: @property, getter and setter

    Learn how to use the @property decorator in Python to create managed attributes with getter, setter, and deleter methods.

  56. Operator Overloading in Python

    Learn how to define custom behavior for Python operators in your classes using special methods like __add__, __mul__, __eq__, and more

  57. Generating Secrets with the secrets Module

    Learn how to generate cryptographically secure random numbers, tokens, and passwords using Python's secrets module.

  58. Persistent Storage with shelve

    Learn how to use the shelve module for simple persistent key-value storage in Python applications.

  59. Template Strings with string.Template

    Learn how to use Python's string.Template class for simple, safe string substitution without the complexity of f-strings or .format().

  60. Creating and Extracting Archives with tarfile

    Learn how to create, read, and extract tar archives using Python's tarfile module with practical examples.

  61. Generic Types and TypeVar in Python

    Master Python generics with TypeVar, Generic, and parametric polymorphism to write flexible, type-safe code that works with any data type.

  62. Compressing Data with zlib

    Learn how to compress and decompress data using Python's zlib module, the foundation for gzip and other compression formats.

  63. Working with JSON in Python

    Learn how to read, write, and manipulate JSON data in Python using the json module.

  64. Making HTTP Requests with requests

    Learn how to make HTTP requests in Python using the requests library—GET, POST, headers, and error handling.

  65. Beautiful Terminal Output with Rich

    Learn how to create stunning terminal output in Python using the Rich library, including colored text, tables, progress bars, and more.

  66. Building CLIs with Typer

    Learn how to create elegant command-line interfaces in Python using Typer, built on Click and type hints.

  67. Python virtual environments: a practical guide

    Create and manage isolated Python virtual environments with venv. Covers activation, requirements files, common errors, and per-project best practices.

  68. Web Scraping with BeautifulSoup

    Learn the fundamentals of web scraping in Python using BeautifulSoup—parsing HTML, navigating the DOM, and extracting data.

  69. Abstract Base Classes with abc

    Learn how to use Python abc module to define abstract base classes that enforce method implementation in subclasses

  70. Async/Await Patterns in Python

    Master async/await patterns in Python—retry logic, timeouts, batching, and error handling for production async code.

  71. Getting Started with asyncio

    Learn asyncio basics—Python's library for async code. Covers coroutines, the event loop, and running concurrent operations.

  72. Building CLI Tools with argparse

    Learn how to create command-line interfaces in Python using the argparse module.

  73. The Descriptor Protocol

    Learn how Python descriptors let you customize attribute access, create reusable property logic, and build more expressive classes.

  74. Working with Environment Variables in Python

    Learn how to read, write, and manage environment variables in your Python applications.

  75. Logging Best Practices in Python

    Take your Python logging to the next level with advanced configuration, handlers, structured logging, and production-ready patterns.

  76. Python Logging for Beginners

    Learn how to use Python logging effectively for debugging and monitoring your applications.

  77. Mocking with pytest: a practical guide

    Use mocking with pytest to replace real dependencies, control side effects, and test edge cases. Covers unittest.mock, pytest-mock, patching, and assertions.

  78. Multiprocessing in Python

    Learn how to use Python multiprocessing to run code in parallel using multiple processes. Covers Process, Pool, shared memory, and synchronization.

  79. Structural Subtyping with Protocol

    Learn how Protocol classes in Python enable structural subtyping, letting you define interfaces without inheritance for flexible duck typing

  80. Getting Started with pytest

    Learn how to write and run tests with pytest, the most popular testing framework in Python. Cover fixtures, assertions, and best practices.

  81. Recipes with itertools

    Practical patterns and recipes for working with Python's itertools module for efficient iteration.

  82. Understanding Metaclasses in Python

    Dive deep into Python metaclasses—understand what they are, how they work, and when to use them to control class creation.

  83. Regular Expressions with the re Module

    Learn to use Python regular expressions for pattern matching, searching, and text manipulation.

  84. SQLite in Python with the sqlite3 Module

    Learn how to create, query, and manage SQLite databases using Python's built-in sqlite3 module.

  85. Running External Commands with subprocess

    Learn how to run external commands from Python, handle their output, and manage process lifecycles effectively.

  86. Threading in Python

    Learn how to use Python threading for concurrent execution. Covers Thread, Lock, Queue, and practical patterns for I/O-bound tasks.

  87. Unit Testing with unittest

    Learn Python built-in unittest framework for writing and running unit tests. Covers TestCase, assertions, fixtures, and test organization.

  88. Python Enums: The enum Module

    Learn how to use Python enums to create sets of named constants with type safety and semantic meaning.

  89. f-strings: Python's String Formatting Power Tool

    Learn how to use f-strings for readable, efficient string formatting in Python.

  90. Functional Programming Patterns in Python

    Learn functional programming patterns in Python: higher-order functions, map/filter/reduce, lambdas, comprehensions, and more.

  91. A Practical Guide to functools.lru_cache in Python

    Learn how to use lru_cache to memoize function results and speed up your Python code with practical examples.

  92. Structural Pattern Matching with match/case

    Learn how to use Python's match/case statements for powerful pattern matching. Covers literals, wildcards, or patterns, and class patterns.

  93. File Paths with pathlib

    Learn how to work with file paths elegantly using Python's pathlib module.

  94. Closures and Variable Scoping in Python

    Learn how closures work in Python, understand variable scope, and see practical examples.

  95. Building APIs with Litestar

    A practical guide to building REST APIs with Litestar, covering route handlers, request validation, dependency injection, and application structure.

  96. Using namedtuple and NamedTuple in Python

    Learn how to create lightweight, immutable record types using namedtuple and NamedTuple from the Python standard library.

  97. Using __slots__ for Memory Efficiency in Python

    Learn how __slots__ can reduce memory usage and improve attribute access speed in your Python classes.

  98. Type Hints in Python

    Learn how to add type hints to your Python code for better readability and tooling support.

  99. Sorting in Python: The key= Parameter

    Learn how to use Python's key parameter for custom sorting with sorted() and list.sort(). Covers lambda functions, itemgetter, attrgetter, and multiple keys.

  100. The Walrus Operator (:=) in Practice

    Learn Python walrus operator for assigning values in expressions. Covers list comprehensions, while loops, and common patterns.

  101. Context Managers and the with Statement

    Learn how Python's with statement and context managers handle resource cleanup reliably, with class-based and decorator-based examples

  102. Reading and Writing YAML in Python

    Learn how to read and write YAML files in Python using the PyYAML library, with examples for configuration files, nested data, and safe loading

  103. Controlling Docker from Python

    Learn how to use the Docker SDK for Python to automate container management, including listing, running, building, and managing containers.

  104. Error Handling with try/except

    Learn how to handle errors gracefully in Python with try/except blocks, multiple exceptions, else/finally, and best practices.

  105. List Comprehensions in Python

    Learn how to use list comprehensions to create lists concisely, with examples of filtering, nested loops, and when to prefer a regular for loop.

  106. Getting Started with Dataclasses

    Learn how to use Python dataclasses to write cleaner, more maintainable classes for storing data — with examples of defaults, immutability, and validation

  107. Python Decorators Explained

    Learn how decorators work in Python, from basic function wrappers to parameterized decorators with practical examples for timing, logging, and caching

  108. Virtual Environments and pip

    Learn how to create isolated Python environments with venv and manage dependencies with pip — essential skills for any Python project

  109. Working with files in Python: read, write, and append

    Practical guide to working with files in Python — open(), read(), write(), context managers, binary mode, pathlib, and error handling.

  110. Building a TCP Server and Client in Python

    Learn how to build TCP servers and clients in Python using the socket module, with threading for multiple connections.

  111. Understanding Python Generators

    A complete guide to generators, yield expressions, and building memory-efficient data pipelines in Python