Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Intermediate Python: Master Decorators From Scratch
Rating: 4.7 out of 5(255 ratings)
17,396 students

Intermediate Python: Master Decorators From Scratch

A Comprehensive Introduction to Decorators In Python with Several Practical Applications
Created byAndy Bek
Last updated 1/2026
English

What you'll learn

  • Understand what decorators are and how they are used in python functional programming
  • Write advanced, flexible decorators to handle caching, performance timing, logging, and more
  • Master the syntax and, more importantly, the core ideas behind decorators
  • Get ample practice through 12 coding assignments, followed by detailed solutions

Course content

1 section36 lectures2h 52m total length
  • VERY Short Intro!1:09
  • Course Resources0:07
  • Introduction to Python Functions7:03

    Introduce Python functions, covering definition and invocation, parameters and default values, and the distinction between print and return, plus pure versus impure functions as groundwork for decorators.

  • Skill Challenge: Averaging Grades0:53
  • Solution2:56
  • More On Functions: *args and **kwargs14:06
  • Skill Challenge: Variadics1:20

    Practice variadics by refactoring the calculate average function to accept a variable number of positional arguments. Add an optional rounding keyword argument to specify decimal places and provide reasonable defaults.

  • Solution2:40
  • Higher-Order Functions7:59
  • Skill Challenge: Arithmetic HOF1:26
  • Solution2:25
  • First-Class Functions6:12
  • Closures7:51
  • Skill Challenge: Counter Factory2:10
  • Solution6:28
  • Basic Introduction To Decorators8:21
  • Decorating Parameterized Functions5:47

    Learn how to create flexible decorators in Python by using *args and **kwargs to decorate functions with any parameter signature, improving reusability and reducing code duplication.

  • Skill Challenge - Let's Log1:46
  • Solution3:07
  • Skill Challenge - Lotto Draws1:04
  • Solution3:07
  • Skill Challenge - Writing A Timer0:43

    Implement a Timed decorator to measure and print a function’s execution time in seconds, then decorate a function that runs for a noticeable duration to test it.

  • Solution5:26
  • Decorators With Arguments8:04
  • Skill Challenge - Repeated Lotto Draws1:05

    Generalize the repeat decorator to invoke any target function n times, as specified, and return a Python list of all numeric outputs (integers, floats, or random outcomes) in sorted order.

  • Solution2:22
  • Chaining Multiple Decorators5:32

    Learn decorator chaining in Python by applying multiple decorators to a function, understand bottom-to-top order, and see how output becomes input, with split and uppercase examples.

  • Preserving Identity With @wraps9:07
  • Skill Challenge - Delaying Downloads3:00

    Implement a decorator to progressively delay downloads per user-resource pair, starting with immediate links and doubling the delay on each subsequent request, using a placeholder download function.

  • Solution6:40
  • Skill Challenge - Authentication Workflow Part I2:09
  • Solution Part I12:45
  • Skill Challenge - Authentication Workflow Part II2:06
  • Solution Part II11:02
  • Skill Challenge - Building A Cache3:00
  • Solution11:30

Requirements

  • Some familiarity with python is preferred, though not strictly required

Description

Welcome to the best and most complete guide to Python decorators!

In this course, you will cultivate a deep and practical understanding of decorators in Python, starting from the very basics. This beginner-friendly course is meticulously crafted to ensure you build a solid foundation from scratch while also getting ample practice in the process.

Before diving into decorators, we'll explore the fundamental principles that serve as the building blocks of this intriguing topic. You'll gain a deep understanding of higher-order functions, closures, and first-class functions – prerequisites that unlock the magic of decorators. Foundational topics include:


  • Closures

  • First-Class Functions

  • Variadics

  • Higher Order Functions

Once we have established a solid grasp of these functional foundations, we'll dive into the captivating world of decorators. We'll start with a gentle introduction and gradually move towards more intricate techniques. Our exploration of decorators will include:


  • Basic Decorators

  • Decorating Parameterized Functions

  • Chaining Decorators

  • Decorating Functions With Variable Arity

  • Preserving Metadata of Decorated Functions


But that's not all! Each concept will be reinforced through engaging coding assignments of increasing difficulty. Throughout the course, will also explore several skill challenges inspired by real-world scenarios including:


  • Logging Function Output

  • Timing Runtime Performance

  • Using Decorators In Mocked Authentication Flows

  • Creating Cache Mechanisms


This course is tailored specifically for Python programmers interested in deepening their understanding of decorators as a gateway to functional programming or as a standalone, intermediate-level programming pattern.

See you inside!

Who this course is for:

  • Beginner Python developers interested in stepping up into intermediate and advance topics