git404hub

what is wtfpython fr?

satwikkansal/wtfpython — explained in plain English

Analysis updated 2026-06-20

36,926PythonAudience · developerComplexity · 2/5LicenseSetup · easy

tl;dr

A collection of Python code snippets that produce baffling, unexpected results, each with a clear explanation of why. Perfect for discovering the quirks that trip up even experienced Python developers.

vibe map

mindmap
  root((wtfpython))
    What it is
      Surprising code snippets
      Detailed explanations
      Educational resource
    Topics covered
      String interning
      Mutable defaults
      Scoping rules
      Float behavior
    Sections
      Strain your brain
      Slippery Slopes
      Hidden treasures
      Deceptive appearances
    Use cases
      Learn Python deeply
      Interview prep
      Avoid real bugs
    Format
      GitHub markdown
      Google Colab notebook

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Discover and understand Python behaviors that cause real-world bugs

VIBE 2

Prepare for technical interviews that test deep Python knowledge

VIBE 3

Level up from beginner to advanced by learning language edge cases

VIBE 4

Run surprising snippets interactively in Google Colab to see the behavior yourself

what's the stack?

Python

how it stacks up fr

satwikkansal/wtfpythonbabysor/mockingbirdhuggingface/pytorch-image-models
Stars36,92636,89736,758
LanguagePythonPythonPython
Setup difficultyeasyhardmoderate
Complexity2/54/53/5
Audiencedeveloperresearcherresearcher

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · easy time til it works · 5min

No installation needed, read directly on GitHub. An interactive Google Colab notebook is also available to run snippets in the browser.

Open-source educational content, free to read, share, and learn from.

in plain english

wtfpython is a collection of surprising, counter-intuitive, or confusing Python code snippets, each followed by a detailed explanation of what is actually happening. The project's tagline is "What the f*ck Python", capturing the reaction developers often have when they run a piece of valid Python code and get output that seems completely wrong. The goal is to explore and explain the underlying mechanics that cause these surprising behaviors. Each example follows a consistent structure: a short code snippet is shown, the output is displayed (which is unexpected), and then a detailed explanation digs into the Python language rules, CPython implementation details, or subtle design decisions that produce that output. Topics covered include Python's string interning (when two strings that look identical are or are not the same object in memory), the behavior of mutable default function arguments, how the "is" operator differs from equality checks, scoping rules in closures, how floating-point numbers behave, the timing of variable evaluation in loops, and many other nuanced behaviors. The examples are organized into sections: "Strain your brain" (the truly surprising ones), "Slippery Slopes" (common pitfalls that lead to real bugs), "Hidden treasures" (obscure but valid Python features), and "Appearances are deceptive" (code that looks different than it behaves). An interactive version is available as a Google Colab notebook. You would use this repository if you are learning Python and want to understand edge cases more deeply, if you are preparing for interviews that probe Python knowledge, or if you simply enjoy learning a language through its quirks. It is a documentation and educational resource, not runnable application code, and the language throughout is Python.

prompts (copy fr)

prompt 1
Explain why Python's mutable default arguments cause unexpected behavior, can you show me an example and a fix?
prompt 2
What's the difference between == and 'is' in Python, and when does it cause bugs? Use examples from wtfpython.
prompt 3
I keep hearing about Python string interning, what is it and when does it matter for my code?
prompt 4
What are the most common Python pitfalls for developers coming from JavaScript or other languages?

Frequently asked questions

what is wtfpython fr?

A collection of Python code snippets that produce baffling, unexpected results, each with a clear explanation of why. Perfect for discovering the quirks that trip up even experienced Python developers.

What language is wtfpython written in?

Mainly Python. The stack also includes Python.

What license does wtfpython use?

Open-source educational content, free to read, share, and learn from.

How hard is wtfpython to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is wtfpython for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.