Changing variable on another module for functions
<p>I have made two py files, in which <strong>main.py</strong> contains:</p>

<pre><code>import module

module.Print("This should not appear.")

module.Silence = False
module.Print("This should appear.")
</code></pre>

<p>The module imported is <strong>module.py</strong> which contains:</p>

<pre><code>Silence = True


def Print(Input, Sil= Silence):
    if Sil == False:
        print(Input)
</code></pre>

<p>The expected result should be:</p>

<blockquote>
  <p>This should appear</p>
</blockquote>

<p>The result:</p>

<blockquote>
  <p></p>
</blockquote>

<p>I think you are looking for a function with a default setting that can be dynamically changed. This will use the global <code>Silence</code> only if the <code>sil</code> argument is omitted in <code>Print()</code> function call.</p>

<pre><code>def Print(input, sil=None):
    if sil is None:
        sil = Silence
    if not sil:
        print(input)
</code></pre>

python python-3.x variables import