Last active
January 15, 2019 13:13
-
-
Save belyaev-pa/d979ddcc756c8286894c5f5ff4003270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decorator(arg1, arg2): | |
def real_decorator(function): | |
def wrapper(*args, **kwargs): | |
print("Congratulations. You decorated a " | |
"function that does something with %s and %s" % (arg1, arg2)) | |
for obj in args: # это список | |
print('hello: {}'.format(obj)) | |
for key, value in kwargs.items(): # это словарь | |
print('key={}, value={}'.format(key, value)) | |
function(*args, **kwargs) | |
return wrapper | |
return real_decorator | |
@decorator("Param1", "Param2") | |
def print_args(*args, **kwargs): | |
for arg in args: | |
print(arg) | |
print_args(1, 2, 3, a=1, b=2, c=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment