Question: Currently I am trying to get a Python 'class functionality' into a function.

Example code:

```
def image_gen(**kwargs):
    anglerange= 45
    print(image_gen.__dict__)
    image_gen.__dict__.update(kwargs)
    print(image_gen.__dict__)
    print(anglerange)

args = dict(anglerange=15)

image_gen(**args)

```

returns:

```
{}
{'anglerange': 15}
45

```

This is not the correct way to solve the argument updating, but what is the correct way for it? In a class you can call `self.update.__dict__`, how is that configured in a function?

I need the argument initialization in the function for a standard copy to run.

Using Python 3.5

Answer: 
I may be misunderstanding this, but I think that the issue that your going to run into is that function data will carry across "instances" in that there is only one copy of the function and all uses of that function are going to share the same object. See the following for an example:

```
# helper function, not really relevant
def print_non_builtins(func):
    orig = dir(func) + ['inspect']
    func.inspect = lambda: {k: getattr(func, k) for k in dir(func) if k not in orig}
    return func

@print_non_builtins
def function_with_data(**kwargs):
    for k, v in kwargs.items():
        setattr(function_with_data, k, v)

function_with_data(a=1, b=2)
print(function_with_data.inspect())
# {'a': 1, 'b': 2}

function_with_data(b=3)
print(function_with_data.inspect())
# {'a': 1, 'b': 3}

```
Unclear logic... Update the dictionary value by key:

```
def image_gen(**kwargs):
 print(kwargs)
 kwargs['anglerange'] = 45
 print(kwargs)

image_gen(**{'anglerange': 15})
{'anglerange': 15}
{'anglerange': 45}

```

Arguments usually do not change in the body of the function, they can be rewritten in cycles, etc. Other examples:

```
def image_gen(anglerange=45):
 print anglerange

image_gen()
45
image_gen(15)
15

```

and

```
def rewrite_example(a):
 i = 0
 i = 1
 while i < 3:
  print("i =", i, a)
  i += 1

rewrite_example('text')
i = 1 text
i = 2 text

```