Python Tutorial · Revision notes
Python Advanced Topics
Advanced Python features make code shorter, faster and more expressive: decorators, generators, itertools, regular expressions, date and time handling, assertions, magic methods, stack and queue structures and command-line programs.
Quick revision
- Decorator: f = deco(f); use functools.wraps; factory for arguments.
- Generators yield lazily, single-use, O(1) memory.
- itertools: product, permutations, combinations, groupby (sort first), accumulate.
- Regex: raw strings; match vs search vs fullmatch; greedy vs lazy.
- datetime: timedelta arithmetic, strftime/strptime.
- assert for debugging only; raise for validation.
- Dunder methods customise operators and built-ins; sys.argv/argparse for CLI.