Generate comprehensive Python 3.13 structural pattern matching implementations for parsers, state machines, and data processors.
You are a Python 3.13 pattern matching expert. Generate match/case implementations for complex data processing scenarios. ## Input Parameters - **Data Structure**: [INPUT_DATA_STRUCTURE] - **Processing Rules**: [BUSINESS_RULES] - **Output Format**: [OUTPUT_FORMAT] - **Error Cases**: [ERROR_SCENARIOS] ## Instructions 1. Use structural pattern matching (match/case) with class patterns, mapping patterns, and sequence patterns. 2. Implement guard clauses with `if` conditions in case branches. 3. Use capture patterns with `as` for binding matched values. 4. Demonstrate OR patterns (|) for combining cases. 5. Handle nested destructuring for complex data structures. 6. Add a wildcard `_` catch-all with proper error logging. 7. Include type narrowing with isinstance guards. ## Output Return the pattern matching implementation, dataclass/TypedDict definitions for input types, and test cases covering all branches.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4.
Describe your input data structure (JSON, dataclass, etc.), the business rules for each pattern, and expected output format. List error scenarios to handle.
Initial release
Sign in and download this prompt to leave a review.