class x:
# we define a decorator
@staticmethod
def decorate_with_kwargs(original_function,**kwargs):
'''
Creating a kwargs decorating decorator to a function
'''
# type = kwargs.get('type', None)
kwargs_dict = kwargs
def new_function(*args,**kwargs):
return original_function(*args,kwargs_dict=kwargs_dict)
return new_function
# here is a function to decorate
@staticmethod
def my_function(msg1,message,**kwargs):
kwargs_dict = kwargs.get('kwargs_dict', None)
print(kwargs_dict.get('type',None))
print(kwargs_dict.get('type2',None))
print(msg1)
print(message)
# and here is how we decorate it
my_function = x.decorate_with_kwargs(x.my_function, type='p',type2='q')
my_function("Hello world!",'well')