Engineering · Skill
Python Resource Management
Python resource management with context managers, cleanup patterns, and streaming. Use when managing connections, file handles, implementing cleanup logic, or building streaming responses with accumulated state.
Open in PhởWhat the skill covers
The sections of its instructions, in order.
- 01 When to Use This Skill
- 02 Core Concepts
- 1. Context Managers
- 2. Protocol Methods
- 3. Unconditional Cleanup
- 4. Exception Handling
- 03 Quick Start
- 04 Fundamental Patterns
- Pattern 1: Class-Based Context Manager
- Pattern 2: Async Context Manager
- Pattern 3: Using @contextmanager Decorator
- Pattern 4: Unconditional Resource Release
- 05 Detailed worked examples and patterns
- 06 Best Practices Summary
Reference files
1 file Phở can open while it uses the skill.
- references/details.md
More in Python development
- Async Python Patterns
Master Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound…
- Python Anti-Patterns Checklist
Use this skill when reviewing Python code for common anti-patterns to avoid. Use as a checklist when reviewing code, before finalizing implementations, or when debugging issues…
- Python Background Jobs & Task Queues
Python background job patterns including task queues, workers, and event-driven architecture. Use when implementing async task processing, job queues, long-running operations, or…
- Python Code Style & Documentation
Python code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or…
- Python Configuration Management
Python configuration management via environment variables and typed settings. Use when externalizing config, setting up pydantic-settings, managing secrets, or implementing…
- Python Design Patterns
Python design patterns including KISS, Separation of Concerns, Single Responsibility, and composition over inheritance. Use this skill when designing a new service or component…
- Python Error Handling
Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception…
- Python Observability
Python observability patterns including structured logging, metrics, and distributed tracing. Use when adding logging, implementing metrics collection, setting up tracing, or…
- Python Packaging
Create distributable Python packages with proper project structure, setup.py/pyproject.toml, and publishing to PyPI. Use when packaging Python libraries, creating CLI tools, or…
- Python Performance Optimization
Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow Python code, optimizing bottlenecks, or improving…
- Python Project Structure & Module Architecture
Python project organization, module architecture, and public API design. Use when setting up new projects, organizing modules, defining public interfaces with __all__, or…
- Python Resilience Patterns
Python resilience patterns including automatic retries, exponential backoff, timeouts, and fault-tolerant decorators. Use when adding retry logic, implementing timeouts, building…
- Python Testing Patterns
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing…
- Python Type Safety
Python type safety with type hints, generics, protocols, and strict type checking. Use when adding type annotations, implementing generic classes, defining structural interfaces…
- UV Package Manager
Master the uv package manager for fast Python dependency management, virtual environments, and modern Python project workflows. Use when setting up Python projects, managing…
Similar engineering skills
Frequently asked questions
What does Python Resource Management do?
Python resource management with context managers, cleanup patterns, and streaming. Use when managing connections, file handles, implementing cleanup logic, or building streaming responses with accumulated state.
Is Python Resource Management free to use?
Yes. Python Resource Management is published by Seth Hobson under the MIT licence, and you can use it with a free Phở account.
How do I use Python Resource Management in Phở?
Press Open in Phở, then Try to apply it to your next message, or add the Python development set so Phở loads it whenever a request matches.
Does Python Resource Management need other tools?
No. It works in a normal Phở chat with what you type or upload.
Copied unchanged from wshobson/agents at commit 7e2fb55 and credited to Seth Hobson, who is not affiliated with Phở. The full instructions and licence text ship with the skill inside Phở.