Learn Python
Quick Reference
Common syntax, commands and checklists for daily Python work.
Syntax
value: int = 42
items = [1, 2, 3]
mapping = {"name": "Ada"}
def double(number: int) -> int:
return number * 2
result = [double(item) for item in items if item > 1]Project commands
python -m venv .venv
python -m pip install -e ".[dev]"
python -m pytest
python -m my_appUseful built-ins
| Function | Purpose |
|---|---|
len() | Number of items |
enumerate() | Index and value |
zip() | Combine iterables |
sorted() | Return sorted values |
sum(), min(), max() | Aggregate numbers |
any(), all() | Test conditions |
isinstance() | Check a runtime type |
Before committing
- Tests pass on a clean environment.
- Inputs and edge cases are handled.
- Formatting and type checks pass.
- Secrets and generated files are excluded.
- The README explains setup and usage.
When debugging
Reproduce the issue, read the full traceback, reduce the input, inspect state with a breakpoint, and add a regression test before applying the fix.