Decorators & exceptions in Python | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite

Decorators & exceptions in Python

Write a decorator named "logo" which takes a sequence of tags and logs a message in case an exception happens within the decorated function. #something like this, ain't sure how to got about it def log(utf8_string, tags): def logo(log): #Example usage @logo('tag_one', 'tag_two') def example(): raise Exception("There's been an error")

6th Jul 2022, 9:19 AM
Timm0x443 - avatar
1 Réponse
Decorators are covered in the Intermediate Python course, lesson 15. A more detailed writeup is here:
6th Jul 2022, 9:58 AM
Tibor Santa
Tibor Santa - avatar