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

Illustration of Python bitwise operators applied to integer bits
Python

Python Bitwise Operator Usage: Syntax and Examples

python bitwise operator usage: Learn how to use Python bitwise operators for flags, bit masking, and efficient integer manipulation with practical examples.

bitwise operatorsPythonbit manipulationflags
Illustration of a binary integer being shifted right by two positions with bits falling off the right edge.
Python

Python Right Shift: Bitwise Behavior and Common Pitfalls

python right shift: Explains Python's right shift operator: bitwise behavior on integers, negative handling, __rshift__ overloading, and common edge cases.

bitwise-operatorspython-operatorsinteger-arithmeticoperator-overloading
Diagram of a binary number being shifted left, with zeros filling the rightmost positions
Python

Python Left Shift: How the << Operator Works

Learn how Python's left shift operator moves integer bits, with practical use cases, edge cases, and performance implications.

PythonBitwise OperatorsLeft ShiftBit Manipulation
Diagram showing the bitwise NOT operation on a binary number with negation result
Python

Python Bitwise NOT: How ~x Works and Why It Returns Negative Numbers

Understand Python's bitwise NOT operator (~), why ~x returns -x - 1, and how to use it to clear and toggle bits without surprises.

bitwise operatorsPython integerstwo's complementbit manipulation
Diagram of two inputs and one output representing the exclusive OR logic gate in Python.
Python

Python XOR Operator: Syntax, Use Cases, and Pitfalls

Learn how the python xor operator (^) works for booleans and integers, with practical use cases, performance notes, and common mistakes.

bitwise operatorsPython syntaxboolean logicexclusive OR
Illustration of bitwise OR combining two binary numbers into a result with a flag mask
Python

Python Bitwise OR: How to Use It in Your Code

Learn how Python's bitwise OR operator combines integer bits, how to use it for flag combinations, and what pitfalls to avoid.

bitwise operatorsPython operatorsinteger bit manipulationflags and masks
Diagram showing the bitwise AND operation on two binary numbers, with highlighted bits and the resulting integer.
Python

Python Bitwise AND: Syntax and Practical Examples

python bitwise and: Learn how Python's bitwise AND operator works, its syntax, practical use cases for flags and masking, and common pitfalls to avoid.

bitwise operatorsPython operatorsbitmaskinginteger manipulation
Illustration of Python bitwise operators showing binary representation and logical gates
Python

Python Bitwise Operators: Syntax, Use Cases, and Pitfalls

Learn how Python bitwise operators work on integers, including syntax, negative-number handling, practical use cases, and common mistakes.

bitwise operatorsinteger operationsbinary arithmeticbit masking
Illustration of the Python not in operator checking absence of an element in a container
Python

Python not in Operator: Syntax and Usage

Learn how Python's not in operator tests membership across lists, sets, dicts, and custom objects, including performance tradeoffs and common mistakes.

membership testingPython operatorscontainer typesperformance
Illustration of the Python in operator checking membership in a set with a magnifying glass over a container
Python

Python's in Operator: Membership Testing Explained

Learn how Python's in operator tests membership in lists, sets, dictionaries, strings, generators, and custom classes, including performance tradeoffs and common pitfalls.

Python OperatorsMembership TestingData StructuresPerformance