Advanced Python Training Course

Course Summary

Ever wondered what a metaclass is? How to speed up your Python program? This is the class for you!

This class will survey advanced features in the Python programming language with a focus on testing and performance.


Duration [top]

4 days.

Objectives [top]

Students will gain familiarity in tools and techniques used in testing, mocking, monkeypatching, and profiling Python applications. Throughout we will explore both the frequently used parts of the stdlib (os, sys, unittest), some of the dusty corners (itertools, functools, contextlib) as well as use popular 3rd party Python packages. The class will feature extensive labs drawn from real-world problems - come prepared to code!

Prerequisites [top]

Prospective students should have previous experience programming in Python.

Outline [top]

Data types and functional programming

  • functions, docstrings, and simple tests with doctest
  • base datatypes overview (list, dict, tuple, set, string)
  • other datatypes: namedtuple, defaultdict, ordereddict, deque, etc
  • function declaration/calling (default values, *args and **kwargs)
  • functional techniques: map/filter/reduce, list.sort, operator module
  • functional closures and simple decorators

Iteration, objects and classes

  • list comprehensions, generator expressions and generator functions
  • fun with iteration: itertools.imap, tee, chain, groupby, etc
  • oop: creating classes, inheritance, mro and super
  • oop features: operator overloading, properties and methods, abstract base classes

Advanced Features and Testing

  • nose (collecting and running tests)
  • test coverage
  • using mocking and monkeypatching in testing
  • writing testable code - dependency injection and refactoring
  • configurable decorators
  • context managers
  • metaclasses and class decorators

Profiling, Performance, and Packaging

  • profiling tools (timeit, %prun, runsnakerun)
  • performance patterns and anti-patterns in Python Code
  • threads, processes and the GIL
  • alternative approaches to parallelization
  • speeding up Python code with Cython
  • creating installable packages and understanding the Python ecosystem

Additional Notes [top]

About the Platform

This course can be taught on most major operating systems, which support Python, such as Windows, Linux, Mac OS X, etc.


"Python" is a registered trademark of the Python Software Foundation. All other marks are the properties of their respective owners.