BugHunt

bool('False') is True

bool() on a string only checks whether it is empty. Every non-empty string, including "False", "0" and "no", is True.

PythonType errors

What it means

Truthiness is about emptiness, not meaning: "" is falsy and any other string is truthy. Config files, environment variables, query strings and form fields all deliver text, so a setting written as false is still on.

Common causes

1. Parsing a config value with bool()

The word is never read.

Breaks

debug = bool(os.environ["DEBUG"])   # "false" -> True

Works

debug = os.environ["DEBUG"].strip().lower() in ("1", "true", "yes")

2. Checking a form checkbox value

Unchecked boxes often send "off" or "0".

Breaks

if form["subscribe"]:

Works

if form.get("subscribe") == "on":

How to find it in your own code

Normalise the text (strip, lower) and compare against the exact words you accept. Treat anything unexpected as an error rather than silently true.

Still not sure why yours breaks?

Paste it into the visualizer and watch it run line by line, with every variable at every step. Free, and it runs in your browser.

Other common errors