SKILL

python-patterns

Pythonic 惯用法、PEP 8 标准、类型提示以及构建健壮、高效、可维护 Python 应用的最佳实践。适用于编写或审查 Python 代码,且涉及惯用结构、类型或 PEP 8 时。

译文已校对
查看英文原文

Pythonic idioms, PEP 8 standards, type hints, and best practices for building robust, efficient, and maintainable Python applications. Use when writing or reviewing Python code and idiomatic structure, typing, or PEP 8 is in question.

适用对象:软件开发与测试。自动收录 · 待核查。

原作者说明节选

从固定版本的 SKILL.md 提取,保留原文语言。以下内容属于作者说明,本站尚未验证安装、兼容或运行结果。

查看英文原文

原文涵盖的主题

  • Python Development Patterns
  • When to Activate
  • Core Principles
  • 1. Readability Counts
  • 2. Explicit is Better Than Implicit
  • 3. EAFP - Easier to Ask Forgiveness Than Permission
  • Type Hints
  • Basic Type Annotations

Idiomatic Python patterns and best practices for building robust, efficient, and maintainable applications. Writing new Python code Reviewing Python code Refactoring existing Python code Designing Python packages/modules Python prioritizes readability. Code should be obvious and easy to understand. Avoid magic; be clear about what your code does. Python prefers exception handling over checking conditions. | Idiom | Description | |-------|-------------| | EAFP | Easier to Ask Forgiveness than Permission | | Context managers | Use with for resource management | | List comprehensions | For simple transformations | | Generators | For lazy evaluation and large datasets | | Type hints | Annotate function signatures | | Dataclasses | For data containers with auto-generated methods | | slots | For memory optimization | | f-strings | For string formatting (Python 3.6+) | | pathlib.Path | For path operations (Python 3.4+) | | enumerate | For index-element pairs in loops | Remember: Python code should be readable, explicit, and follow the principle of least surprise. When in doubt, prioritize clarity over cleverness.

来源仓库
affaan-m/ECC
源文件
pi/core/skills/python-patterns/SKILL.md
固定版本
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
阅读完整原作者说明 ↗

来源与内容状态

本条为自动发现的元数据,尚未完成人工文档核查;适用性与运行结果待核查。

原作者:affaan-m/ECC · 原作者仓库元数据。文档核查:未核查。最近来源检查:2026-11-09T15:01:43.197Z。

分类由名称、说明与路径规则生成,分类不代表已核实适配。

许可与权利归属

MIT。第三方内容及版权归原作者,使用条件以原文为准。

许可原文 ↗

本站没有因同步、复制或用户自报成功而将资源标为运行验证通过。

限制与注意事项

  • 元数据收录不代表本站已经安装、适配、实测或进行安全审查。