Decorators & exceptions in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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
Timm0x443 - avatar
1 Answer
0
Decorators are covered in the Intermediate Python course, lesson 15. A more detailed writeup is here: https://realpython.com/primer-on-python-decorators/
6th Jul 2022, 9:58 AM
Tibor Santa
Tibor Santa - avatar