python-expert
Python Expert — Gotchas & Decisions
Use Context7 for FastAPI/Django/Flask docs.
Key Decisions
decisions[4]{choice,use_when}:
FastAPI vs Django vs Flask,"FastAPI: async APIs + auto-docs. Django: full-featured + ORM + admin. Flask: minimal/micro"
Pydantic vs dataclass,"Pydantic for validation/serialization (API boundaries). dataclass for internal structs"
SQLAlchemy vs Django ORM,"SQLAlchemy: standalone/FastAPI. Django ORM: Django projects only"
sync vs async,"async for I/O-bound (HTTP/DB). sync for CPU-bound. Don't mix blocking calls in async"
Gotchas
- Mutable default args:
def f(items=[])shares list across calls — usedef f(items=None): items = items or [] asyncio.run()creates new event loop — can't nest. Useawaitinside existing async context- FastAPI
Depends(): new instance per request by default. Use@lru_cachefor singletons - Django N+1: use
select_related(FK/OneToOne) andprefetch_related(M2M/reverse FK) isinstance(x, int)catchesbooltoo —boolis subclass ofint. Checktype(x) is intif needed- Type hints are NOT enforced at runtime — use Pydantic or
beartypefor runtime validation dict.get('key')returnsNonesilently — usedict['key']when key must existrequirements.txtvspyproject.toml: prefer pyproject.toml (PEP 621) for modern projectswithstatement for resource cleanup (files, DB connections) — never rely on__del__
More from nguyenthienthanh/aura-frog
stitch-design
Generate UI designs using Google Stitch AI with optimized prompts
36angular-expert
Angular 17+ gotchas and decision criteria. Covers signals vs observables, standalone patterns, and common pitfalls Claude gets wrong.
31flutter-expert
Flutter/Dart mobile expert. PROACTIVELY use when working with Flutter, Dart, mobile apps. Triggers: flutter, dart, widget, bloc, riverpod
16seo-expert
SEO and search engine optimization expert. PROACTIVELY use when working with meta tags, structured data, Core Web Vitals, sitemap, robots.txt, canonical URLs. Triggers: SEO, meta tags, schema markup, search ranking
13dev-expert
Development patterns for React, Vue, Laravel, Next.js, React Native - state management, forms, API integration
13react-native-expert
React Native best practices expert. PROACTIVELY use when working with React Native, mobile apps, Expo. Triggers: react-native, expo, mobile, iOS, Android, NativeWind
13