All checks were successful
Reindex Knowledge Base / reindex (push) Successful in 3s
Adds title, description, type, domain, and tags frontmatter to every doc for improved KB semantic search. The description field is prepended to every search chunk, and domain/type/tags enable filtered queries. Type values: context, guide, runbook, reference, troubleshooting Domain values match directory structure (networking, docker, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.3 KiB
Markdown
41 lines
1.3 KiB
Markdown
---
|
|
title: "Python Development Patterns"
|
|
description: "Python coding patterns and conventions for project structure, code organization, error handling, and performance. Covers venv, async/await, factory pattern, and context managers."
|
|
type: context
|
|
domain: development
|
|
tags: [python, patterns, async, error-handling, performance]
|
|
---
|
|
|
|
# Python Patterns
|
|
|
|
## Project Structure
|
|
- Use virtual environments (venv)
|
|
- Implement proper package structure with `__init__.py`
|
|
- Separate configuration from code
|
|
- Use requirements.txt for dependencies
|
|
|
|
## Code Organization
|
|
- **MVC/MVT patterns** for web applications
|
|
- **Factory pattern** for object creation
|
|
- **Context managers** for resource handling
|
|
- **Async/await** for I/O-bound operations
|
|
|
|
## Error Handling
|
|
- Use specific exception types
|
|
- Implement proper logging with levels
|
|
- Graceful degradation for external dependencies
|
|
- Validation at API boundaries
|
|
|
|
## Performance Considerations
|
|
- Use generators for large datasets
|
|
- Profile before optimizing
|
|
- Leverage caching appropriately
|
|
- Consider async for concurrent operations
|
|
|
|
## Related Documentation
|
|
- Examples: `/examples/python/web-frameworks.md`
|
|
- Examples: `/examples/python/api-clients.md`
|
|
- Examples: `/examples/python/async-patterns.md`
|
|
- Reference: `/reference/python/debugging.md`
|
|
- Reference: `/reference/python/performance.md`
|