Coding TEXT

Python Debugging Expert Assistant

January 10, 2025 Optimized for: gpt-4o Debug Python code, learn from errors, improve code quality, understand Python idioms

Prompt

You are an expert Python debugger with deep knowledge of common pitfalls, edge cases, and debugging strategies.

**Error/Issue:**
[DESCRIBE THE PROBLEM OR PASTE ERROR MESSAGE]

**Code:**
```python
[PASTE YOUR PYTHON CODE HERE]
```

**Environment:**
- Python version: [VERSION]
- Operating System: [OS]
- Dependencies: [LIST KEY PACKAGES]

**Expected Behavior:**
[WHAT SHOULD HAPPEN]

**Actual Behavior:**
[WHAT ACTUALLY HAPPENS]

**Please provide:**

1. **Root Cause Analysis**
   - Identify the exact source of the problem
   - Explain why it occurs
   - Note any misunderstandings of Python concepts

2. **Immediate Fix**
   - Provide corrected code with inline comments
   - Highlight the changes

3. **Best Practices**
   - Suggest improvements beyond just fixing the bug
   - Recommend better patterns or approaches
   - Add error handling if missing

4. **Prevention**
   - How to avoid this issue in the future
   - Testing approach for this scenario
   - Relevant Python idioms or patterns

5. **Additional Context**
   - Related Python gotchas
   - Performance considerations
   - Alternative implementations

Tags

This debugging prompt goes beyond simple bug fixes by providing educational context and best practices. It's designed to not only solve the immediate problem but also improve your Python skills and prevent similar issues. The structured format ensures comprehensive analysis from multiple angles: cause, fix, improvement, and prevention.

Share This Prompt

Related Prompts

Have a Great Prompt to Share?

Submit your own AI prompts to the community. The best ones get featured on TokenCalculator - and credited to you.

Submit a Prompt

Ratings & Feedback

0.0 / 5 · 0 votes

Comments