Naftuli Kay
Naftuli Kay

Reputation: 91630

Why did Python choose to use None instead of null?

Python seems to be created to be a fast, minimal language for getting stuff done. While I love Python, one thing has never made sense to me. Why name a null entity None rather than Null or even null? Save a character for free! Does anyone know why this road was taken in Python?

Upvotes: 13

Views: 1770

Answers (1)

Borealid
Borealid

Reputation: 98469

This is a philosophical question: you're asking "why?".

Nonetheless, here's one answer: Python strives to be legible even for people who do not understand the language. This line:

if foo is None:

Reads better than this one:

if (foo == null) {

In normal English grammar, "null" isn't a thing. It's an adjective, not a noun. "None" is a noun, which is how you use it in computer science.

Upvotes: 9

Related Questions