Learn Intermediate Python 3
Go beyond the basics: flexible function arguments, namespaces and scope, higher-order functions and decorators, deeper object-oriented design, exceptions and unit tests, iterators and generators, specialized collections and context managers.
- Intermediate level
- 8 modules
- 57 lessons
- 198 tasks and questions
Syllabus
01Function argumentsWrite functions that accept arguments flexibly: defaults without the mutable-default trap, *args, **kwargs, every parameter kind together, and unpacking with * and **.7 lessons
02Namespaces and scopeHow Python stores names: built-in, global, enclosing and local namespaces, the LEGB lookup rule, and changing outer variables with global and nonlocal.6 lessons
03Functions deep diveTreat functions as values: dispatch tables, higher-order functions and factories, the built-in map, filter, reduce, sorted and friends, and decorators with and without arguments.6 lessons
04Object-oriented programmingDesign with classes: inheritance and composition, overriding and super(), polymorphism and duck typing, special methods, abstract base classes and properties.9 lessons
05Exceptions and unit testingHandle and design errors well, from the exception hierarchy to custom exceptions and chaining, then prove your code works with unittest: assertions, expected errors, subtests and fixtures.8 lessons
06Iterators and generatorsSee how iteration works under the hood, write your own iterators, use itertools, and produce data lazily with generator functions, expressions, pipelines and send().7 lessons
07Specialized collectionsPick the right container: sets and frozensets, deque, namedtuple, defaultdict and Counter, OrderedDict and ChainMap, and your own containers built on UserDict and UserList.8 lessons
08Resource managementRelease files, connections and other resources reliably with the with statement: write context manager classes, handle exceptions in __exit__, build managers from generators, and combine several at once.6 lessons