Python Language Concepts: Create Decorators to Add Functionality to Existing Functions

Start Course
level
Introductory
Subject
Software Development
Course Length
53 minutes
Subscription
Foundation

Course Description

The Decorator pattern is a general concept that can be used in many programming languages. Python has a particular notion of what a decorator is: it is a function that takes a function or class and returns a new function or class. These Python decorators can be automatically applied to functions or classes by prepending an "@" to the name, and using it as part of the function or class definition. In this course, you'll see a lot of examples of how and why you would use a decorator. We'll go in-depth to thoroughly understand what a decorator actually does and how to easily build your own from scratch.

Requirements

  • Students should already be comfortable with Python language fundamentals, including: writing and using classes, methods, and functions, using container objects (e.g., list or dictionary), using decorators, using string formatting, using conditional operators

Instructors

Michael Dougherty

Michael Dougherty is an experienced full-stack engineer, functional programming aficionado, and musician. When he was 13 he brought a "Learn C++ in 21 days" book with him on a family vacation, and he has been writing code ever since. For the past few years, Michael has worked as a Web Development Mentor, as a Full Stack Senior Software Engineer, as well as on several side projects.