Python 有用的资源

Official docs, style guide, packaging, and the references worth bookmarking.

Beginner
Key PointsThe official docs and PEP 8 are the only sources that stay correct; blog posts rot, docs get versioned.

Official Documentation

docs.python.org is versioned — switch between 3.10/3.12/3.13 on the page. Always check it before third-party blog posts for signatures.

ResourceURLUse it for
Language referencedocs.python.org/3/referenceGrammar and semantics
Standard librarydocs.python.org/3/libraryModule APIs
Tutorialdocs.python.org/3/tutorialGuided learning
PEP indexpeps.python.orgDesign decisions
PyPIpypi.orgPackage search

Style and Typing

PEP 8 defines naming, indentation and import order. Do not enforce it by hand — ruff formats and lints in one command.

Bash
pip install ruff
ruff check .          # 静态检查
ruff format .         # 格式化(兼容 black)

pip install mypy
mypy app/ --strict    # 类型检查

Packaging

Modern projects declare metadata and dependencies in pyproject.toml (PEP 621), build with build, publish with twine.

TOML
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "myapp"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["fastapi>=0.110"]
Bash
python -m build            # 产出 dist/*.whl 与 *.tar.gz
twine upload dist/*

Reading Source

For "why is it designed this way", the CPython source or the library's GitHub issues beat search engines.

Python
import json
print(json.__file__)      # 本地模块路径,直接打开看实现
Keep three bookmarks: official docs, PEP index, PyPI. Treat every other tutorial as second-hand.

Friends & Partners