title: How to pass variables with values in decorators?
body: <p>My task is passing a variable with a values in decorator which would replace the variable to it value as key in dictionary, something like this:</p>
  <pre><code>@parameters(param1 =  parameter1)
  x = function(param1 = 1, param2 = 2)
  extract {paramter1:1, param2:2}
  </code></pre>
  <p>my current code is:</p>
  <pre><code>def dump_args(func):
          def wrapper(*args, **kwargs):
              variables = {}
              func_args = signature(func).bind(*args, **kwargs).arguments
              func_args = dict(func_args)
              # print(func_args)
                  # to get values that are not passed and defautlt values
              sig = signature(func)
              for param in sig.parameters.values():
                  if ( param.default is not param.empty):
                      if param.name not in func_args:
                          if type(param.default) in [int, str, float, bool]:
                              func_args[param.name] = param.default
                      else:
                          if param.default == 0:
                              del func_args[param.name]
              
              print(func_args)
              variables = {**variables, **{key: value for key, value in func_args.items() if type(value) in [int, float, bool, str] and key not in variables}}
              print(variables)
              # return func(*args, **kwargs)
          return wrapper
  
  @dump_args
  def test(a, b=4, e=0, c=&quot;blah-blah&quot;, d= 4.5, val=True):
      pass
  dic= {'name': 'sparsh'}
  test(1, 'hola', dic, False)
  </code></pre>
  <p>Output is like this:
  {'a': 1, 'b': 'hola', 'c': False, 'd': 4.5, 'val': True}
  {'a': 1, 'b': 'hola', 'c': False, 'd': 4.5, 'val': True}</p>
  <p>what i want to do is when i put the decorator in below function like</p>
  <pre><code>@dump_args(b = stringvalue)
  def test(a, b=4, e=0, c=&quot;blah-blah&quot;, d= 4.5, val=True):
      pass
  </code></pre>
  <p>and this function is called then in the final dictionary the <code>b</code> key will be replaced by <code>integervalue</code> key and output should be like this:</p>
  <pre><code>{'a': 1, 'stringvalue': 'hola', 'c': False, 'd': 4.5, 'val': True}
  {'a': 1, 'stringvalue': 'hola', 'c': False, 'd': 4.5, 'val': True}
  </code></pre>
  <p>can anyone tell me how to do this. Thanks in advance</p>