Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Access Control Decorator | Decorator Practice Lab
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python Decorators Explained

bookChallenge: Access Control Decorator

Task

Swipe to start coding

Write a decorator called require_admin that restricts access to the decorated function. The function should only run if the global variable IS_ADMIN is True. If IS_ADMIN is not True, the decorator must raise a PermissionError. The decorator must work for any function it decorates.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 3
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Access Control Decorator

Swipe to show menu

Task

Swipe to start coding

Write a decorator called require_admin that restricts access to the decorated function. The function should only run if the global variable IS_ADMIN is True. If IS_ADMIN is not True, the decorator must raise a PermissionError. The decorator must work for any function it decorates.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 3
single

single

some-alt