Browse by Topic

Popular

Latest

Latest Posts

Diagram showing conversion between Python string and bytes objects with encoding and decoding arrows.
Python

Python Bytes: Creation, Conversion, and Operations

Learn how to create, convert, and manipulate Python bytes objects, including encoding, decoding, binary file handling, and common pitfalls.

bytesencodingbinary-datastring-conversion
Illustration of a Python namedtuple being matched by a match/case structure with labeled fields.
Python

Python Namedtuple Pattern Matching with match/case

Python's structural pattern matching works well with namedtuples. Learn to match by type, capture fields, use guards, and handle nested data.

pythonnamedtuplepattern-matchingmatch-case
Illustration of a Python dataclass object being matched against multiple pattern cases in a match statement.
Python

Python Dataclass Pattern Matching

Learn how to use Python's structural pattern matching with dataclasses, including class patterns, guards, nested patterns, and common pitfalls.

pattern matchingdataclassesstructural pattern matchingPython 3.10
Diagram of a Python class pattern matching a data object with match statement branches.
Python

Python Class Pattern Matching: Syntax and Practical Use

Learn how to use Python class pattern matching with match statements, including positional and keyword patterns, __match_args__, guards, nested patterns, and common pitfalls.

pattern matchingmatch statementclass patternsstructural pattern matching
Diagram showing how match_args maps dataclass fields to pattern matching positions.
Python

Python match_args in Dataclasses

Learn how Python match_args controls which dataclass fields participate in structural pattern matching and how to customize it.

PythonDataclassesPattern Matching__match_args__
Illustration of Python class pattern matching showing a match statement branching to different class shapes.
Python

Python Pattern Matching Classes: Using Match with Class Patterns

python pattern matching classes: Learn how to use Python's structural pattern matching with classes: capture attributes, match nested objects, and use guards effectively.

pattern matchingPython classesmatch statementstructural pattern matching
Illustration of nested f-string syntax showing an f-string inside another f-string's braces, with a focus on readability and formatting.
Python

Python Nested F-Strings: Syntax and When to Avoid Them

Learn how nested f-strings work in Python, when nesting is useful, and why it often hurts readability. Includes syntax examples, common pitfalls, and safer alternatives.

f-stringsstring formattingPython syntaxcode readability
Code editor showing a Python f-string debug line with variable name and value displayed
Python

Using Python f-String Debug to Print Variable Names and Values

python f string debug: Learn how the `=` specifier in Python f-strings prints variable names and values for faster debugging, with formatting and compatibility notes.

Pythonf-stringsdebuggingstring formatting
Diagram showing how Python f-strings convert objects to string using repr versus str
Python

Python f-string repr: Using the !r Conversion Flag

Learn how to use the !r conversion flag in Python f-strings to display repr() output, and how to customize __repr__ for better debugging.

f-stringsreprstring formattingpython debugging
A clock and calendar icon with Python f-string syntax showing datetime formatting.
Python

Python F-String Datetime Formatting

Learn how to format datetime objects directly in Python f-strings using strftime format codes, timezone handling, and practical examples.

f-stringsdatetime formattingstrftimeformat specifiers