Advanced Python course
For those who know the basics: the techniques used in real projects. In DMarlon Studio, Python powers desktop apps (tkinter), Flask websites and the console: design the window and the studio writes the Python code.
Start- 1List, dict and set comprehensionsBuild lists, dicts and sets in a single line with Python comprehensions, including filters and unpacking. Try it in DMarlon Studio.Lesson 1
- 2*args, **kwargs and keyword-only argumentsPython functions that accept any number of arguments with *args and **kwargs, plus arguments that can only be passed by name.Lesson 2
- 3Lambdas, sorted, map and filterSort, filter and transform data in Python with lambda functions, sorted(key=...), map and filter, using a product catalogue.Lesson 3
- 4Closures and nonlocalFunctions that return functions and remember their variables: Python closures, and nonlocal to change them, with discounts and tickets.Lesson 4
- 5DecoratorsAdd logging and permission checks to Python functions without touching them: decorators, decorators with arguments and functools.wraps.Lesson 5
- 6Generators and yieldProcess a server log line by line with Python generators: yield, next(), chained generators and generator expressions.Lesson 6
- 7The iterator protocolHow a for loop works inside: iter(), next(), StopIteration, and a custom Python class with __iter__ and __next__ that pages results.Lesson 7
- 8Classes and objectsObject-oriented programming in Python: classes, __init__, self, attributes, methods, properties and __str__, with players in a role-playing game.Lesson 8
- 9Inheritance and super()Reuse and specialise Python classes with inheritance: subclasses, super(), method overriding, isinstance and the MRO, using a payroll.Lesson 9
- 10Special methodsMake your objects print, compare, add up and measure like built-in Python ones with __repr__, __eq__, __lt__, __add__ and __len__.Lesson 10
- 11DataclassesPython dataclasses with @dataclass: free __init__, __repr__ and __eq__, field(default_factory), __post_init__, frozen and order.Lesson 11
- 12Enums and match/caseOrder states with Enum and events handled with match/case in Python: value, mapping and sequence patterns, captures and guards.Lesson 12
- 13Custom exceptions and context managersCreate your own exceptions and context managers in Python: with, __enter__, __exit__, contextlib.contextmanager and suppress, in a warehouse.Lesson 13
- 14Type hints, protocols and genericsPython type hints: aliases with type, typing.Protocol for structural typing and generic functions with the Python 3.12 syntax.Lesson 14
- 15Counter, defaultdict, deque and namedtupleThe data structures in Python's collections module: Counter, defaultdict, deque and namedtuple, applied to the sales of a coffee shop.Lesson 15
- 16itertools and functoolsHandy tools from Python's standard library: accumulate, combinations, chain, count, islice and groupby, plus lru_cache, reduce and partial.Lesson 16
- 17Recursion and memoizationRecursive Python functions to walk a folder tree, and memoization with a dictionary to count the ways to pay an amount.Lesson 17
- 18JSON and regular expressionsRead and write JSON with Python's json module and pull data out of a log with regular expressions: named groups, findall and sub.Lesson 18
- 19asyncio with async and awaitAsynchronous Python with asyncio: coroutines with async and await, gather to run tasks together, sleep(0) and wait_for with a timeout.Lesson 19
- 20Project: a tested inventoryA small Python inventory that brings together classes, dataclasses and custom exceptions, checked with assert tests. Run it in DMarlon Studio.Lesson 20