Fundamentals 10 min read

Why Does Python Do Things Differently? 9 Surprising Design Decisions Explained

This article explores nine common questions about Python’s design—from mandatory indentation and missing semicolons to the ellipsis literal, for‑else syntax, elif, the absence of a main() function, zero‑based indexing, the Global Interpreter Lock, and the difference between == and is—providing historical context, official explanations, and practical code examples.

Data Party THU
Data Party THU
Data Party THU
Why Does Python Do Things Differently? 9 Surprising Design Decisions Explained

1. Why Python Uses Indentation to Manage Code Blocks

If you come from C/C++, Java, JavaScript, Go or similar languages, Python’s mandatory indentation may feel uncomfortable because other languages rely on braces.

Guido van Rossum explained that using indentation for grouping is elegant and greatly improves readability for ordinary Python programs.

Guido van Rossum believes that using indentation for grouping is very elegant and significantly improves the clarity of ordinary Python programs. Most people fall in love with this feature after using it for a while.

In short, the decision was made by Python’s creator and is considered a wise choice.

Python even includes a built‑in Easter egg that reminds you of this rule: from __future__ import braces Running the above produces a custom SyntaxError: not a chance indicating that braces are not allowed.

2. Why Python Statements Do Not Need a Semicolon

In C, C++ and Java, semicolons are ubiquitous because older compilers needed them to parse code mechanically.

Modern compilers are smart enough to infer statement boundaries, and Python follows the Zen principle “Simple is better than complex.”

Many newer languages are also moving away from mandatory semicolons.

3. Why Python Has an Ellipsis Literal

Python allows the ellipsis ( ...) as a placeholder for incomplete code blocks.

def my_function():
    ...

Guido van Rossum said that some people find writing such incomplete code cute.

Some people think it’s cute to be able to write incomplete code like that.

4. What the For‑Else Syntax Does

The for‑else construct is often misunderstood. The else block runs only when the loop finishes without encountering a break.

leaders = ["Elon", "Tim", "Warren"]
for i in leaders:
    if i == "Yang":
        print("Yang is a leader!")
        break
else:
    print("Not found Yang!")

Since “Yang” is not in the list, the loop completes without a break, and the else block executes.

5. Why Python Uses elif Instead of else if

Python replaces the traditional else if with the concise elif, keeping the language tidy and elegant.

6. Why Python Does Not Require a main() Function

Unlike compiled languages that need a defined entry point, Python scripts execute top‑to‑bottom, making a main() function optional.

def main():
    pass

if __name__ == '__main__':
    main()

7. Why Python Uses Zero‑Based Indexing

Historically, many early languages (C, C++, Python) adopted zero‑based indexing because it aligns with pointer arithmetic and memory addressing.

8. Why Python Has a Global Interpreter Lock (GIL)

The GIL, introduced when Python was created in 1991, simplifies thread safety and keeps the interpreter lightweight.

Today, with multi‑core CPUs, the GIL limits CPU‑bound multithreaded performance, leading to criticism.

Starting with Python 3.13, the GIL will be gradually removed, and Python 3.14 will officially support a free‑threaded build (PEP 779).

9. Why == Is Not is in Python

==

checks for value equality, while is checks for object identity (whether two references point to the same object).

a = 256
b = 256
print(a is b)   # True (cached small integer)

x = 257
y = 257
print(x is y)   # False (outside cache range)

Python caches integers in the range [-5, 256], making is and == appear equivalent for those values, but they differ outside that range.

Conclusion

Designing a programming language is an art that blends technical, historical, and even emotional considerations. While some decisions may seem odd or imperfect, they contribute to Python’s elegance and widespread appeal.

ellipsisglobal interpreter lockindentationfor-elseequality vs identityzero-indexing
Data Party THU
Written by

Data Party THU

Official platform of Tsinghua Big Data Research Center, sharing the team's latest research, teaching updates, and big data news.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.