Skip to content

Instantly share code, notes, and snippets.

@belyaev-pa
Last active January 15, 2019 13:13
Show Gist options
  • Save belyaev-pa/d979ddcc756c8286894c5f5ff4003270 to your computer and use it in GitHub Desktop.
Save belyaev-pa/d979ddcc756c8286894c5f5ff4003270 to your computer and use it in GitHub Desktop.
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