本文基于 Frost Ming “friendly python” 标签下的文章,整理出偏向工程实践的开发范式、规范与典型好/坏代码范式示例。重点是“对使用者友好 + 对维护者友好”,并强调在 Python 中利用语言特性与生态扩展点进行合理抽象。
🏃♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import chess | |
| import chess.engine | |
| from collections import defaultdict | |
| from marvin import ai_fn, ai_model | |
| from pydantic import BaseModel, Field | |
| def describe_board(board, illegal_moves): | |
| result = "" | |
| me = board.turn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| import re | |
| from typing import Any, Never | |
| class JSONParseError(Exception): | |
| pass | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local obj = {} | |
| obj.__index = obj | |
| -- Metadata | |
| obj.name = "HammerspoonSwitchIME" | |
| obj.version = "0.1" | |
| obj.author = "Qiangning Hong" | |
| obj.license = "MIT" | |
| local ENGLISH_ID = "com.apple.keylayout.US" |
OlderNewer