Python has come a long way since 2.7.
Back then:
-
print
was still a statement - type hints didn’t exist
-
%
formatting was the default
Today, we write functions very differently.
# Python 2.7
def greet(name):
print "Hello, %s" % name
# Python 3.10+
def greet(name: str) -> str:
return f"Hello, {name}"
And with Python 3.12, we even get more concise typing with list[str]
, |
for unions, and better error messages.
In my full article, I walk through:
- Type hints (from
typing.List[str]
→list[str]
) - F-strings replacing
%
and.format()
- Structural Pattern Matching (Python 3.10)
- Why
print
had to change from statement → function
Read the full deep dive on Medium: Evolution of Functions in Python: From Python 2.7 to Today
Top comments (0)