
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Students will become familiar with decorators in Python and with the common use of their equivalents in other programming languages, such as Annotations in Java, and Attributes in C#.
Demonstrates how a simple decorator in Python decorates a function by wrapping it with an inner function that uppercases the decorated function's output.
Learn to implement a lowercase decorator in Python that wraps a function, returns a new function, calls the original function, and converts its output to lowercase letters.
Develop a decorator for functions with one or more parameters by returning a new function that preserves the original signature, including an uppercase transformation shown in a morning greeting example.
Learn how to use a class as a decorator in Python by implementing init and call, ensuring the signature matches the decorated function and the class instance replaces the call.
Learn how a class's factory function can be decorated to decorate the class itself, with a decorator that intercepts object creation and prints a message during rectangle instantiation.
Explore how to create decorators with arguments to configure behavior, printing custom text when a function or class instance is invoked, by returning a decorator that wraps the target.
Explore real world decorators in Python, similar to annotations and attributes, including timing, logging, and caching, plus mapping classes to tables and testing in libraries and frameworks.
Explore solutions to every quoting exercise, and request explanations via short videos as needed, with ongoing assistance and improved content for decorators in Python.
This course covers one of the more difficult topics in Python. Explaining it step by step throughout the course, using code samples and diagrams will provide you with the desired in-depth understanding, not only in Python but in other programming languages as well. The coding exercises this course includes will allow you to asses the level of understanding you achieve.