how to override default values needed by function in module?
<p>I'm trying to figure out how I can override default values of functions that are defined inside some module. Consider this code (<code>program.py</code>):</p>

<pre><code># import the default &amp; user defined settings
from default_settings import *
from my_settings import *

# import some functions, which might be dependent on the settings above
from functions import *

# call dummy_function from 'functions' - prints '1'
dummy_function()

# output SOME_DEFAULT - will be '1'
print SOME_DEFAULT

# re-import 'my_settings' - SOME_DEFAULT will now be '2'
from my_settings import *
print SOME_DEFAULT
</code></pre>

<p>here is <code>default_settings.py</code>:</p>

<pre><code>DO_DEBUG = False
SOME_DEFAULT = 1
</code></pre>

<p>here is <code>my_settings.py</code>, who's values I'd like to use inside <code>functions.py</code>:</p>

<pre><code>DO_DEBUG = True
SOME_DEFAULT = 2
</code></pre>

<p>This is <code>functions.py</code>, where I need to import <code>default_settings</code>, otherwise I get an NameError. I don't want to import <code>my_settings</code> here, because <code>functions.py</code> should be more like a generic library.</p>

<pre><code># if I leave this line out, then I get a 
# "NameError: name 'SOME_DEFAULT' is not defined"
from default_settings import *

# I don't want to add "from my_settings import *" here, because 'functions.py' 
# is supposed to be a generic library of functions.

# dummy decorator.
def do_profile(cond):
    def resdec(f):
        if cond:
            print "profiling!"
        return f
    return resdec


# dummy function depending on both 'DO_DEBUG' and 'SOME_DEFAULT'
@do_profile(DO_DEBUG)
def dummy_function(bla=SOME_DEFAULT):
    print bla
</code></pre>

<p>If I run <code>python program.py</code> I get the following output:</p>

<pre><code>1
1
2
</code></pre>

<p>This is expected. The first <code>1</code> comes from <code>dummy_function</code>, the second <code>1</code> comes from the import of <code>default_settings</code> inside <code>functions</code> and the <code>2</code> is a result of me re-importing <code>my_settings</code>. </p>

<p>Is there a way that I can override the default settings that are needed by <code>dummy_function</code> by simply using <code>my_settings</code>? I thought about leaving out the <code>from default_settings import *</code> line in <code>functions</code>, but then I run into <code>NameError</code>. Is there a way to import from <code>functions</code> and at the same time pass on all variables into <code>functions</code>?</p>
