You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
Kirill Salnikov edited this page Mar 31, 2021
·
13 revisions
Markdown code blocks are styled when card is added to Anki. It looks like this:
---1. How to create a parameterized decorator in *Python*?> You have to wrap the decorator function inside another function that will take arguments and return a decorator: >> ```python> def check_non_negative(index):> def validator(f):> def wrap(*args, **kwargs):> if args[index] < 0:> raise ValueError(> f'Argument {index} must be non-negative'> )> return f(*args, **kwargs)> return wrap> return validator> > @check_non_negative(1)> def create_list(value, size):> return [value] * size> ```---