Python Skill
Best Practices
- PEP 8: Follow standard style guide (Snake case for vars, 4 spaces indent).
- Type Hints: Use
typingmodule (List, Optional, etc.) for robust code. - Virtual Envs: Always use
venvorpoetry. Never install global pip packages. - Exceptions: Catch specific exceptions (
ValueError), never bareexcept:.
Common Pitfalls
- Mutable Defaults:
def func(list=[]):causes bugs. UseNoneinstead. - GIL: Threads don't speed up CPU tasks. Use
multiprocessing.
References
Converted and distributed by TomeVault — claim your Tome and manage your conversions.