Pages

Topics

Tools

↑↓navigate↵openescclose

Python guides

Every published Python guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Python guides

Diagram showing a Python raw string literal with backslashes treated as literal characters
Python

Python Raw String Literals: Syntax and Use Cases

python raw string literal: Learn how Python raw string literals treat backslashes literally, and when to use them for regex patterns, file paths, and other backslash-h...

PythonRaw StringsRegular ExpressionsEscape Sequences
A Python raw string literal with an r prefix representing a regex pattern and a Windows file path.
Python

Python Raw String: Syntax, Use Cases, and Limitations

Learn how Python raw strings work, why the r prefix preserves backslashes, and when to use them for regex patterns and Windows file paths.

raw stringspython syntaxregular expressionsfile paths
Diagram showing triple quotes creating a multiline string in Python code.
Python

Python Multiline String: Syntax and Pitfalls

python multiline string: Learn how to create and manage multiline strings in Python, including triple quotes, indentation handling, f-strings, and common pitfalls.

multiline stringstriple quotesf-stringstextwrap
Python code editor showing a triple quoted string spanning multiple lines with syntax highlighting.
Python

Python Triple Quoted Strings: Syntax and Use Cases

python triple quoted string: Learn how to use Python triple quoted strings for multi-line text, docstrings, and raw strings, with practical examples and common pitfalls.

Pythontriple quotesdocstringsmulti-line strings
Python code editor showing a string literal with both single and double quotes, illustrating the difference in escaping.
Python

Python Single vs Double Quotes: Syntax and Style

In Python, single and double quotes are interchangeable for string literals. This guide covers escaping, triple quotes, f-strings, and PEP 8 style recommendations.

pythonstring literalssyntaxPEP 8
Illustration of Python string literal syntax with quotes and escape characters.
Python

Python String Literal: Syntax and Escapes

Understand Python string literal syntax: quoting styles, escape sequences, raw strings, f-strings, and bytes literals, along with common pitfalls.

string literalsPython syntaxescape sequencesraw strings
Illustration of Python string immutability showing two separate string objects after concatenation
Python

Python String Behavior and Common Operations

python string: Understand Python string immutability, common methods, slicing, formatting, and performance tradeoffs for working developers.

python stringsstring methodsimmutabilitystring formatting
Illustration comparing Python's zip and enumerate functions for parallel and indexed iteration.
Python

Python zip vs enumerate: When to Use Each

Learn when to use Python's zip and enumerate for parallel iteration and indexed loops, with practical examples and performance insights.

Pythonzipenumerateiteration
Illustration comparing Python's enumerate and range functions for loop iteration with index and value.
Python

Python enumerate vs range: When to Use Each

Understand the difference between Python's enumerate and range for indexed iteration, and learn which to use for readable, efficient loops.

Pythonenumeraterangeiteration
Illustration of Python zip strict mode raising a ValueError when iterable lengths differ, with aligned and misaligned elements.
Python

Python zip strict: Enforcing Equal-Length Iterables

How Python's zip(strict=True) enforces equal-length iterables, with practical examples, edge cases, and compatibility notes.

Pythonzipstrictiterables