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

Python chr function converting an integer to a Unicode character, illustrated with a code point and resulting character.
Python

Python chr Function: Converting Integers to Characters

Learn how to use Python's chr() function to convert integers to Unicode characters, handle errors, and avoid common pitfalls.

PythonUnicodechrord
A visual representation of Python's ord() function turning the character 'A' into the integer 65.
Python

Python ord Function: Character to Integer

Use Python's built-in ord() function to convert single characters to Unicode code points, avoid common errors, and see practical examples.

Pythonord()Unicodechr()
Illustration of a Unicode character being converted to an ASCII escape sequence by the Python ascii() function.
Python

Python ascii() Function: Escaping Non-ASCII Characters

Learn how Python's ascii() function converts objects to ASCII-safe printable strings, escapes Unicode characters, and differs from repr().

ascii functionPython builtinsreprUnicode escaping
Illustration of Python repr function showing an object converted to a string representation.
Python

Python repr Function: How It Works and When to Use It

Python's repr() returns unambiguous string representations. See how to override __repr__ in your classes and when to use repr() instead of str().

pythonreprdebugging__repr__
Illustration of a Python dictionary with keys being hashed into buckets, representing the hash function concept.
Python

Python Hash Function: Usage and Customization

Understand Python's hash() function, its role in dicts and sets, and how to implement custom __hash__ and __eq__ correctly.

hash()dictionariescustom __hash__hash randomization
A visual metaphor showing Python objects in memory with unique identity markers, illustrating the id() function.
Python

Understanding Python's id() Function

python id function: Explore how Python's id() function returns object identity, how CPython assigns memory addresses, and when relying on id() is safe or misleading.

pythonobject identitymemory addressbuilt-in functions
Illustration of a Python object becoming callable through the __call__ method, shown as a function-style button with a state container.
Python

What Makes an Object Callable in Python

Learn what makes an object callable in Python, how callable() works, and when implementing __call__ creates a useful callable object.

pythoncallable()__call__functools.partial
Illustration of Python all() function checking a list of boolean values, with a checkmark for true and an X for false.
Python

Python all() Function: Syntax, Usage, and Edge Cases

Learn how Python's all() function works, its syntax, behavior on empty iterables, and practical usage with generator expressions.

PythonBuilt-in FunctionsIterablesBoolean Logic
Diagram showing Python's any() function short-circuiting through a list of boolean values, stopping at the first truthy element.
Python

Python any() Function: Behavior, Use Cases, and Pitfalls

Python's any() function returns True if any element in an iterable is truthy. Learn how truthiness, short-circuiting, and generator expressions fit into validation code and common pitfalls.

Pythonbuilt-in functionsiterablesgenerator expressions
A sieve filtering a stream of data items, with some passing through and others being left behind, representing the Python filter function.
Python

Python filter function: syntax and usage

python filter function: Learn how the Python filter function works, its syntax, and when to use it over list comprehensions, with practical examples.

Pythonfilterlambdalist comprehension