Specific features
Abstract Syntax Trees
- How to use Abstract Syntax Trees (AST) to understand code
- Learn Python ASTs, by building your own linter
- Abstract Syntax Trees in Python
Async and concurrency
- Async IO in Python: A Complete Walkthrough
- Async Python in real life
- Concurrency and async / await — asynchronous code, concurrency, and parallelism
- Basics of concurrency — concurrency landscape, APIs, docs, books, and glossary
- Python Concurrency: The Tricky Bits
- Speed Up Your Python Program With Concurrency — threading, asyncio, and multiprocessing
Command line applications
- Python docs HOWTOs: Argparse Tutorial
- click — creating beautiful command line interfaces in a composable way with as little code as necessary
- Rich — make your command line applications visually appealing and present data in a more readable way
- Textual — Text User Interface framework for Python inspired by modern web development
Context managers
- The Magic of Python Context Managers
- Python with Context Managers
- Context Managers — text and video tutorial
CPython internals
- Python behind the scenes — CPython virtual machine, how CPython compiles a program, main parts of the interpreter, etc
- CPython Object System Internals: Understanding the Role of PyObject — understand how objects are implemented in CPython and how CPython emulates Inheritance and Polymorphism in C using struct embedding
Decorators and closures
- stackoverflow: Decorators demystified
- Python Decorators
- Decorator library
- Closures and Decorators in Python
- Python Inner Functions: What Are They Good For?
- Solving Logic Problems with Python Decorators
Exception handling
- Python docs: Errors and Exceptions
- Handling exceptions in Python like a PRO
- Exceptions And Errors — text and video tutorial
Iterables, Generators, Yield, Itertools
- stackoverflow: What does the yield keyword do? — also explains iterables and generators
- Yield and Generators Explained
- How to make an iterator in Python
- Python docs: itertools — functions creating iterators for efficient looping
- Itertools Hacks — Avoiding nested loops, Infinite loop with a count, etc
- Page iterator in Python
Lambda
- A Guide to Python Lambda Functions
- calmcode.io: lambda — video, includes usage in
pandas
- Yet Another Lambda Tutorial
Lists and comprehensions
- stackoverflow: Slice notations and assignments
- A Comprehensive Guide to Slicing in Python
- List comprehensions explained visually
- Comprehensions in Python the Jedi way
- calmcode.io: comprehensions — video
- stackoverflow: How to copy 1-D and multi-D lists
- Python docs: collections — container datatypes
Logging
Memoization
OS interaction
- stackoverflow: How to execute a program or call a system command from Python?
- stackoverflow: difference between subprocess and os.system
- stackoverflow: How to use subprocess command with pipes?
- stackoverflow: when should shell=True be avoided?
- stackoverflow: How to iterate over files in a given directory?
- Python pathlib Cookbook: 57+ Examples to Master It
- pathlib module: taming the file system
Pattern matching
- Pattern matching tutorial for Pythonic code
- PEP 636: Structural Pattern Matching Tutorial
- Structural Pattern Matching in Python
Profiling code and speeding up Python
- Python docs: deterministic profiling of Python programs
- Speed up your code
- Profiling and Analyzing Performance of Python Programs
- stackoverflow: How can you profile a Python script?
- Easy speedup wins with Numba
- How Numba and Cython speed up Python code
Python Packaging
- Packaging Python Projects — walks you through how to package a simple Python project
- stackoverflow: What is setup.py?
- Packaging and Distribution
- How to create a Python package in 2022
- Publishing Python Packages — book covering how to create masterful, maintainable Python packages, includes pro tips for design, automation, testing, deployment, etc
Regular Expressions
- Understanding Python re(gex)? — my book on regular expressions, covers built-in
re
and third-partyregex
modules- Interactive app with 100+ regex exercises — based on practice problems from my book
- PyRegexPlayground — interactive playground for Python Regular Expressions
- Python regular expression cheatsheet — my blog post, includes examples as well
- regex101 — visual aid and online testing tool for regular expressions, select flavor as Python before use
- debuggex — railroad diagrams for regular expressions, select flavor as Python before use
- Awesome Regex — curated collection of libraries, tools, frameworks and software
Socket Programming
Standard library
- PyMOTW-3 — how to use the modules of the Python standard library
- Python Standard Library changes in recent years
Type annotations
Virtual Environments
On newer versions of Python, I use the simple commands shown below to create a new virtual environment. This approach should work out-of-the-box, but might depend upon the OS you are using. I'm on Linux.
# this is needed only once
# 'new_project' is the name of the folder, can be new or already existing
# use py instead of python3.12 for Windows
$ python3.12 -m venv new_project
$ cd new_project/
$ source bin/activate
(new_project) $ # pip install <modules>
(new_project) $ # do some scripting
(new_project) $ deactivate
$ # you're now out of the virtual environment
Here's some resources on this messy topic: