Python Patterns
构建健壮、高效且易于维护的 Python 应用程序的 Python 惯用法(Pythonic idioms)、PEP 8 标准、类型提示(Type hints)以及最佳实践。
Install
/plugin marketplace add xu-xiang/everything-claude-code-zhThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add xu-xiang/everything-claude-code-zh --skill python-patternsgit clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh.git /tmp/everything-claude-code-zh
mkdir -p ~/.claude/skills
cp -r /tmp/everything-claude-code-zh/skills/python-patterns ~/.claude/skills/python-patternsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Python 开发模式 (Python Development Patterns)
用于构建健壮、高效且易于维护的应用程序的 Python 惯用模式与最佳实践。
## 何时激活
- 编写新的 Python 代码时
- 评审 Python 代码时
- 重构现有的 Python 代码时
- 设计 Python 包(Packages)或模块(Modules)时
## 核心原则
### 1. 可读性至上 (Readability Counts)
Python 优先考虑可读性。代码应当直观且易于理解。
```python
# 推荐:清晰且可读
def get_active_users(users: list[User]) -> list[User]:
"""仅从提供的列表中返回活跃用户。"""
return [user for user in users if user.is_active]
# 不推荐:虽然精简但令人困惑
def get_active_users(u):
return [x for x in u if x.a]
```
### 2. 显式优于隐式 (Explicit is Better Than Implicit)
避免使用“魔法”;确保代码的行为清晰透明。
```python
# 推荐:显式配置
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# 不推荐:隐藏的副作用
import some_module
some_module.setup() # 这行代码具体做了什么?
```
### 3. EAFP - 宽恕好过许可 (Easier to Ask Forgiveness Than Permission)
Python 倾向于使用异常处理而非预先检查条件。
```python
# 推荐:EAFP 风格
def get_value(dictionary: dict, key: str) -> Any:
try:
return dictionary[key]
except KeyError:
return default_value
# 不推荐:LBYL (Look Before You Leap) 风格
def get_value(dictionary: dict, key: str) -> Any:
if key in dictionary:
return dictionary[key]
else:
return default_value
```
## 类型提示 (Type Hints)
### 基础类型标注Details
- Skill name
python-patterns- Repository
- xu-xiang/everything-claude-code-zh
- Path
skills/python-patterns/SKILL.md- License
- MIT
- Repo updated
- 5 March 2026
FAQ
What does the Python Patterns skill do?
构建健壮、高效且易于维护的 Python 应用程序的 Python 惯用法(Pythonic idioms)、PEP 8 标准、类型提示(Type hints)以及最佳实践。
How do I install the Python Patterns skill?
Claude Code plugin: /plugin marketplace add xu-xiang/everything-claude-code-zh. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Python Patterns popular?
It lives in xu-xiang/everything-claude-code-zh, which has 2,037 GitHub stars and 332 forks.
Related skills
Backend Patterns
2kxu-xiang/everything-claude-code-zh
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
Coding Standards
2kxu-xiang/everything-claude-code-zh
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
Frontend Patterns
2kxu-xiang/everything-claude-code-zh
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
Springboot Patterns
2kxu-xiang/everything-claude-code-zh
Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理与日志。适用于 Java Spring Boot 后端开发。
Python Patterns
2kxu-xiang/everything-claude-code-zh
Pythonic 惯用法、PEP 8 标准、类型提示,以及构建稳健、高效且可维护 Python 应用的最佳实践。
Debug
1.1kagentic-community/mcp-gateway-registry
Debug issues in the MCP Gateway Registry using first-principles thinking. Invoke when something is broken, timing out, returning errors, or behaving unexpectedly. Forces structured root-cause analysis before any code change is proposed.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.