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

bookChallenge: Access Control Decorator

Compito

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.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 3
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookChallenge: Access Control Decorator

Scorri per mostrare il menu

Compito

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.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 3
single

single

some-alt