O'Reilly logo
live online training icon Live Online training

Pythonic design patterns

Building on your knowledge of OOP

Aaron Maxwell

Much has been written about design patterns—reusable solutions to common problems involving classes and objects. But most of it was written for languages like Java, C++, and C#. While these patterns all apply to Python, they apply differently because as a language, Python has a very different set of features.

In this hands-on three-hour course, expert Pythonista Aaron Maxwell helps you build on your existing knowledge of object-oriented programming to learn how Python’s dynamic type system, first-class functions, and other compelling features translate into uniquely Pythonic applications of traditional design patterns.

What you'll learn-and how you can apply it

By the end of this live, online course, you’ll understand:

  • How design patterns in Python differ from Java, C++, and C#
  • Properties in Python—how they work, the different design patterns based on them, and the implications for refactoring
  • The observer pattern and its uniquely Pythonic variations
  • Factory patterns in Python and how to extend them across inheritance hierarchies

And you’ll be able to:

  • Write Python code that’s concise, readable, and highly maintainable
  • Advise your teammates on potently powerful Python patterns and crucial best practices
  • Apply the design patterns covered in this class to your Python code in powerful new ways
  • Better understand other design patterns you encounter in relation to Python’s object mode

This training course is for you because...

  • You're a web developer using Python frameworks, and you want to expand your knowledge.
  • You’re a QA engineer using Python for scripting and writing tests, and you want to explore design patterns in more detail.
  • You’re a data scientist using Python, and you want to get more done, faster.
  • You’re a software engineer aiming to be more productive and write more robust, reliable, and maintainable Python code.
  • You want to improve your Python knowledge to ace an interview or land that dream job.
  • You want to deeply understand the Python language and ecosystem and how to use it to its fullest potential.

Prerequisites

  • Complete the Python Labs Prep
  • An intermediate understanding of Python (e.g., the ability to write simple Python programs using lists, dictionaries, and classes) and Python object-oriented programming (equivalent to Pythonic Object-Oriented Programming)
  • Familiarity with defining your own classes and methods and creating simple inheritance hierarchies

Materials or downloads needed in advance:

A machine with Python 3 (3.6+) or Python 2.7 installed along with the Python-aware IDE or editor of your choice (e.g., PyCharm)—You will be able to do the programming exercises in either version of Python. Since almost everything in the course applies to both versions, the class will be taught primarily using 3, pointing out where 2.7 is different as we go along. You should be able to open a Python interactive interpreter on the command line and run simple programs ("python3 helloworld.py") either on the command line or in your IDE. On Windows, you will need to set your system path.

Recommended preparation:

Introduction to Python (video)

Intermediate Python: Introduction (video)

Pythonic Object-Oriented Programming (live online training)

Recommended follow-up:

Python Cookbook, 3rd edition (book)

Become Fluent in Python (Learning Path)

Magically Crafting Your Own Python Syntax (Oriole online training)

Fluent Python: The Power of Special Methods (Oriole online training)

Python: The Next Level (live online training)

About your instructor

  • Aaron Maxwell is author of the book "Powerful Python: The Most Impactful Patterns, Features, and Development Strategies Modern Python Provides." As a software engineer, he has worked in devops, test automation, and machine learning, and now divides his time between coding, writing, and teaching

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

This course will cover:

  • Python’s object syntax
  • Overview of Python object model special features
  • Properties for clean design and refactoring
  • Special methods
  • How OOP in Python is fundamentally different from other languages
  • The observer pattern
  • The factory patterns