New Python concepts and fundamentals to Learn in 2025

Updated: July 20, 2025, 09:28 PM IST

Here’s a curated list of new Python concepts and fundamentals, focusing on features introduced in recent Python versions (3.8 to 3.12) along with code examples. These features are useful for both learning and writing more modern, readable, and efficient Python code.

🆕 1. Walrus Operator (:=) – Python 3.8

Assign values inside expressions.

python
Copy Copied!
n = len(my_list)
if n > 5:
    print(f"List is long: {n} elements")

# With Walrus Operator
if (n := len(my_list)) > 5:
    print(f"List is long: {n} elements")


🆕 2. Positional-Only Parameters – Python 3.8

Restrict arguments to be positional only using /.

python
Copy Copied!
pythonCopyEditdef greet(name, /):
    print(f"Hello, {name}!")

greet("Alice")  # ✅
greet(name="Alice")  # ❌ TypeError

🆕 3. f-string Debugging – Python 3.8

Print both expression and value with =.

python
Copy Copied!
pythonCopyEditx = 10
print(f"{x=}")  # Output: x=10


🆕 4. Type Hinting Enhancements – Python 3.9+

Use built-in generics like list, tuple, dict for type hints.

python
Copy Copied!
pythonCopyEditdef greet_all(names: list[str]) -> None:
    for name in names:
        print(f"Hello {name}")

🆕 5. Pattern Matching (match-case) – Python 3.10

A more readable alternative to long if-elif chains.

python
Copy Copied!
def http_error(status):
    match status:
        case 400:
            return "Bad Request"
        case 404:
            return "Not Found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something else"

🆕 6. Union Types with | Operator – Python 3.10

Cleaner syntax for optional or multiple types.

python
Copy Copied!
pythonCopyEditdef square(num: int | float) -> int | float:
    return num * num


🆕 7. Exception Groups and except* – Python 3.11

Handle multiple exceptions raised in parallel (e.g., in async code).

python
Copy Copied!
try:
    raise ExceptionGroup("group", [ValueError("a"), TypeError("b")])
except* ValueError as e:
    print("Caught value error:", e)


🆕 8. Self Type Hint – Python 3.11

Used to annotate methods that return instances of their class.

python
Copy Copied!
from typing import Self

class MyBuilder:
    def set_value(self, val) -> Self:
        self.val = val
        return self

🆕 9. Mutable vs Immutable Data Classes – Python 3.10+



python
Copy Copied!
from dataclasses import dataclass
@dataclass(frozen=True)
class Point:
    x: int
    y: int


frozen=True makes it immutable like a namedtuple.

🆕 10. New Syntax Features in Python 3.12

  • Faster, simpler f-string parsing
  • More powerful error messages
  • Subinterpreters for parallelism (experimental)

python
Copy Copied!
# 3.12 allows multi-line f-strings and comments inside them
name = "Alice"
age = 30
print(f"""
Hello, {name}
You are {age} years old  # This is valid now in 3.12
""")
Data
hello world beautiful
nice world new
second journey column