Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did Python choose to use None instead of null?

Tags:

python

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?

like image 274
Naftuli Kay Avatar asked Oct 05 '22 09:10

Naftuli Kay


1 Answers

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.

like image 71
Borealid Avatar answered Oct 10 '22 04:10

Borealid