coding-python
Purpose
This skill equips the AI to generate, debug, and optimize Python 3.12+ code using core features and libraries, focusing on practical implementations for data handling, async operations, and web services.
When to Use
Use this skill for tasks involving data analysis (e.g., with pandas/numpy), building RESTful APIs (e.g., FastAPI), asynchronous processing (e.g., async/await), data validation (e.g., pydantic), or environment management (e.g., venv/uv). Apply it when code requires type hints for maintainability or dataclasses for simple structs, especially in projects needing fast iteration.
Key Capabilities
- Python 3.12 Features: Use async/await for non-blocking I/O; define dataclasses with
@dataclassdecorator; enforce type hints viafrom typing import List(e.g.,def func(x: int) -> str:). - Standard Library: Leverage
asynciofor event loops (e.g.,asyncio.run(main())); usevenvfor isolated environments (e.g.,python -m venv myenv). - uv Tool: Alternative to venv; install with
pip install uv, then create env viauv venv myenvand activate withsource myenv/bin/activate. - Libraries: FastAPI for async web apps (e.g., define routes with
@app.get("/")); pandas for data frames (e.g.,df = pd.DataFrame(data)); numpy for arrays (e.g.,np.array([1, 2, 3])); pydantic for models (e.g.,from pydantic import BaseModel; class Item(BaseModel): name: str).
Usage Patterns
To accomplish tasks, structure code as follows: Import necessary modules first (e.g., import asyncio, fastapi); use async functions for I/O-bound operations (e.g., async def fetch_data(): await asyncio.sleep(1)); wrap scripts in virtual environments for dependency isolation. For projects, initialize with python -m venv .venv then install dependencies via pip install fastapi pandas numpy pydantic. When generating code, ensure type hints are included (e.g., def add(a: float, b: float) -> float: return a + b). For async patterns, run the event loop explicitly: asyncio.run(main()). Always check for compatibility with Python 3.12+ by specifying in shebang or requirements.txt.
Common Commands/API
- CLI Commands: Create venv with
python -m venv env_name --prompt env_name(use--copiesflag for Windows); activate viasource env_name/bin/activateon Unix orenv_name\Scripts\activateon Windows; run scripts withuv run script.py --watchfor auto-reload. Install packages:pip install fastapi[all]oruv add fastapi. - API Endpoints/Methods: In FastAPI, define an endpoint like:
from fastapi import FastAPI; app = FastAPI(); @app.get("/items/{item_id}") async def read_item(item_id: int): return {"item_id": item_id}. For pandas, usedf.groupby('column').mean(); for numpy,np.dot(array1, array2); for pydantic, validate data withitem = Item(name="example"). - Config Formats: Use JSON for FastAPI configs (e.g.,
{"debug": true}in settings.py); environment variables for keys (e.g.,os.environ.get('API_KEY')); requirements.txt for dependencies (e.g.,fastapi>=0.95.0\npandas==2.0.0).
More from alphaonedev/openclaw-graph
playwright-scraper
Playwright web scraping: dynamic content, auth flows, pagination, data extraction, screenshots
1.4K3d-modeling
Skill for creating and editing 3D models using software like Blender for AR/VR applications.
71nano-pdf
PDF processing: extraction, text mining, form filling, manipulation, OCR integration
60market-data
Fetches and processes real-time financial market data for analysis and trading.
56playwright-mcp
Playwright MCP server: browser automation via MCP protocol, page interaction, form filling
48financial-reporting
Generates and analyzes financial reports using data aggregation, visualization, and compliance tools.
47