LoongLee's blog

Python

Python

Definition

Python is a high-level, interpreted, general-purpose programming language created by Guido van Rossum in 1991.

Core Features

  • Clean and Elegant: Clear syntax close to natural language
  • Strong Dynamic Typing: Types determined at runtime, but type errors raise exceptions
  • Rich Standard Library: "Batteries included" philosophy
  • Cross-Platform: Runs on Windows, macOS, and Linux
  • Multi-Paradigm: Supports object-oriented, functional, and procedural programming

Data Model Concepts

Variables as References

x = 5
y = x  # x and y point to the same object 5
x = 10  # x points to new object 10, y still points to 5

Parameter Passing

  • Immutable objects (int, str, tuple): Modifications inside functions don't affect external variables
  • Mutable objects (list, dict): Modifications inside functions affect external variables

Important Modules

  • pathlib: Object-oriented path operations
  • collections: Advanced data structures (Counter, defaultdict, OrderedDict)
  • itertools: Iterator building blocks
  • functools: Higher-order functions and operations on callable objects
  • asyncio: Asynchronous I/O, event loop, coroutines