Changing local variables inside functions or methods in python
<p>I'm extending an open source python product, but I can't change the code directly as that would make merging with upstream changes harder.</p>

<p>So instead of changing the function directly I want to manipulate the local variable inside the function from another place. I want to add a key to a dictionary which is created inside the function as local variable. How would I be able to change this local dic variable? Is this possible?</p>

<p>Take as example the below code:</p>

<pre><code>import functools
class API(object):

    def update_resources(self, host):
        bla = sflkj
        dic = {
            'cpu': 5,
            'memory': 500
        }

class APIExtension(API):
    def update_resources(self, host):
        # But first do our changes to the function here
        # The change that I want to do is add a key: 'workload'
        # this is the function I want to change the dic variable to include workload
        super(APIExtension, self).update_resources
</code></pre>
