Python 程式設計/命名約定
外觀
在 Python 程式中,有各種各樣的命名約定。
PEP 0008 指定了類名(例如 GenericTree)、包和模組名(例如 generictree 和 generic_tree)、函式和變數名(storestate 或 store_state;混合大小寫是不推薦的)等的命名約定。Google Python 風格指南遵循類似的命名約定。
以上與 Java 命名約定(例如,方法名 storeState)和 C# 命名約定(例如,方法名 StoreState)形成對比。
在 Python 2 中,標準庫包含多個偏離 PEP 0008 的地方。例如,Tkinter 模組以 Tkinter(大寫 T)拼寫;這在 Python 3 中被重新命名為 tkinter。
- 命名約定 在 PEP 0008:Python 程式碼風格指南,python.org
- 命名 在 Google Python 風格指南,google.github.io
- pycodestyle - Python 風格指南檢查器,pypi.python.org
- 要重新命名的模組 在 PEP 3108,python.org
- W:命名約定(程式設計)