hands-on lab

Python: Decorators

Difficulty: Advanced
Duration: Up to 1 hour
Students: 81
Rating: 3.6/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

Learn how to wrap callables using Python's decorator syntax.

Decorators allow callables to be expanded or augmented without modifying the original. They're commonly used in web application frameworks for routing, authentication, etc. They're used to parameterize unit tests with pytest. In addition to many other use cases.

This lab introduces decorators through hands-on examples and ends with the chance to practice what you've learned.

Prerequisites:

  • Proficient with:
    • The Python runtime
    • The Python language syntax

Covered topics

Lab steps

Web IDE Review
Decorators
Demonstrate Your Knowledge
Solution