Skip to content

Chapter 1 of 8

Python Foundations and Principles

Python is a high-level, interpreted, dynamically typed language created by Guido van Rossum in 1991. The language is shaped by PEP 8, its official style guide, and PEP 20, Tim Peters' Zen of Python, which articulates guiding principles such as readability and explicitness. Python 3 is the actively maintained line; Python 2 reached end-of-life in 2020. The reference implementation is CPython, written in C. Alternative implementations include PyPy, which uses JIT compilation for speed, and Jython, which runs on the Java Virtual Machine.

Pythonic coding style favors clarity over cleverness. The principle "easier to ask forgiveness than permission" (EAFP) encourages trying an operation and catching exceptions rather than checking conditions up front, in contrast to "look before you leap" (LBYL). Values are evaluated as truthy or falsy in boolean contexts: empty containers, the integer 0, and None are falsy, while most other values are truthy. Boolean operators short-circuit, so `and` and `or` stop evaluating once the result is determined. Two related idioms follow: `x is None` checks specifically for None and is preferred over `== None`, while `not x` is true for any falsy value, not only None.

Comparison semantics distinguish identity from equality. The `==` operator checks value equality, while `is` checks identity — whether two names refer to the same object in memory. Similar syntactic distinctions appear throughout the language: the `match` statement uses pattern matching rather than equality with `==`, and the walrus operator `:=` assigns a value within an expression, enabling reuse of computed values without separate statements.

All chapters
  1. 1Python Foundations and Principles
  2. 2Core Data Types and Type Concepts
  3. 3Iteration, Generators, and Comprehensions
  4. 4Functions, Decorators, and Modules
  5. 5Object-Oriented Programming and Dunder Methods
  6. 6Type Hinting and Modern Language Features
  7. 7Concurrency: GIL, Threads, Processes, and Async
  8. 8Standard Library, Tooling, and Ecosystem

Drill it

Reading is not remembering. These come from the Python Deep Dive deck:

Q

What is Python?

A high-level, interpreted, dynamically typed programming language created by Guido van Rossum in 1991.

Q

What is PEP 8?

Python's official style guide.

Q

What is PEP 20?

The Zen of Python — guiding principles by Tim Peters.

Q

What is the difference between Python 2 and Python 3?

Python 3 is the actively maintained version; Python 2 reached end-of-life in 2020.