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

Editorial illustration showing the seven Python arithmetic operators arranged around a division symbol, representing operator precedence and numeric behavior.
Python

Python Arithmetic Operators: Syntax and Behavior

A practical reference to Python's arithmetic operators, covering true vs floor division, modulo with negatives, precedence, type coercion, and common pitfalls.

pythonarithmetic-operatorsnumeric-typesoperator-precedence
Illustration of a Python type conversion error with a warning sign and data type symbols
Python

Handling Python Type Conversion Errors

A practical guide to Python type conversion errors: how to distinguish TypeError from ValueError, handle common edge cases, and write robust conversion helpers.

type conversionValueErrorTypeErrorexception handling
Diagram showing conversion between Python bytes, string, integer, and hexadecimal representations.
Python

Python Bytes Conversion: Encoding, Decoding, and More

Learn how to encode strings to bytes, decode bytes to text, convert bytes to integers and hex, and handle encoding errors with clear Python examples.

bytesencodingdecodingbinary data
Illustration of a Python dictionary being converted into objects, JSON strings, and typed values with arrows showing the transformation flow.
Python

Python Dict Conversion: Objects, JSON, and Type Casting

Learn how to convert Python dicts to objects, JSON strings, and typed values, including nested structures, custom encoders, and common failure handling.

PythondictionariesJSONdataclasses
A list of duplicate items flowing into a set container that outputs only unique elements, illustrating Python set conversion.
Python

Python Set Conversion: Lists, Tuples, and Casting

Python set conversion explained: convert lists, tuples, and strings to sets, cast element types with comprehensions, and understand hashability constraints.

pythonsettype conversiondata structures
Illustration of a Python tuple being converted into a list, set, and dictionary, showing the transformation of immutable to mutable structures.
Python

Python Tuple Conversion: Lists, Sets, Dictionaries

Learn how to convert Python tuples to lists, sets, dictionaries, and strings, and back to tuples, with clear examples and performance tradeoffs.

tuplelist conversionset conversiondictionary conversion
A diagram showing various Python data types such as tuples, sets, and strings being converted into a single list container.
Python

Python List Conversion: Convert Data Types to Lists

Practical python list conversion: converting tuples, strings, sets, generators, and ranges into lists, plus element type conversion and memory tradeoffs.

pythonlisttype-conversioniterables
Python code showing conversion of an object to a string with str() and repr()
Python

Python String Conversion: str(), repr(), and Formatting

Understand how Python objects become strings with str(), repr(), f-strings, and format(). See the differences and how to control output.

str()repr()f-stringsstring formatting
A visual metaphor for converting data types to floating-point numbers in Python.
Python

Python Float Conversion: Handling Strings and Edge Cases

Learn how to safely convert strings, ints, and other types to float in Python, handle errors, and avoid precision pitfalls.

floattype conversionerror handlingprecision
Illustration of Python casting showing conversion between data types like integer, string, and float.
Python

Python Casting: Explicit Type Conversion Explained

Learn how Python casting works: explicit conversion with built-in functions, implicit coercion, container conversions, and common pitfalls.

type conversiontype coercionbuilt-in functionsdata types