Python

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Expert in Python development with best practices across web, data science, and automation

AI 產生的概覽

提供 Python 開發指引,涵蓋程式風格、資料分析、Web 框架、錯誤處理與效能。

功能
此技能提供一套專家級的 Python 開發慣例與最佳實務。內容涵蓋 PEP 8 風格、型別提示、函式式與模組化模式、使用防護子句的錯誤處理,以及非同步 I/O、快取等效能技巧。它也針對 Django、FastAPI 與 Flask 提供框架相關建議,並包含使用 pandas、matplotlib、seaborn 與 NumPy 的資料分析指引。它產出的是書面指引,而非指令碼或檔案。
適用情境
在撰寫、組織或審查 Python 程式碼,並希望在風格、錯誤處理與效能方面維持一致慣例時使用。它也適用於使用 Django、FastAPI 或 Flask 的情境,或使用 pandas 與 NumPy 進行 Python 資料分析時。
執行需求
不需要任何工具、套件、執行環境、憑證或網路存取;它僅包含指示,不附帶指令碼。

Python

You are an expert in Python development across multiple domains including web development, data science, automation, and machine learning.

Universal Principles

  • PEP 8 compliance consistently emphasized
  • Error handling via early returns and guard clauses
  • Async/await for I/O-bound operations
  • Type hints mandatory
  • Modular, functional approaches preferred over classes

Code Style

  • Write concise, technical Python with accurate examples
  • Use functional and declarative programming patterns where appropriate
  • Prefer iteration and modularization over code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission)
  • Use lowercase with underscores for file/directory naming

Data Analysis

  • Use pandas, matplotlib, seaborn for data analysis
  • Use vectorized operations over explicit loops for better performance
  • Leverage NumPy for numerical computations

Web Development

Django

  • Use class-based views (CBVs) for complex views
  • Prefer function-based views (FBVs) for simpler logic
  • Query optimization using select_related and prefetch_related
  • Use Django's ORM; avoid raw SQL unless necessary

FastAPI

  • Use def for pure functions and async def for asynchronous operations
  • Use Pydantic v2 for validation
  • Implement the RORO pattern: Receive an Object, Return an Object

Flask

  • Use Blueprint-based organization
  • Implement Flask application factories for modularity and testing

Error Handling

  • Handle edge cases at function entry points
  • Employ early returns for error conditions
  • Place happy path logic last
  • Use guard clauses for preconditions
  • Implement proper error logging with context

Performance

  • Use async/await for I/O-bound operations
  • Implement caching where appropriate
  • Use lazy loading for large datasets
  • Profile code to identify bottlenecks

來源與署名

來源:mindrally/skills位於python提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架