Using global variable as default parameter
<p><strong>a.py</strong></p>

<pre><code>#!c:/Python27/python.exe -u

from connection import Connection
import globals

globals.server_ip = '192.168.0.1'
connection = Connection()
</code></pre>

<p><strong>globals.py</strong></p>

<pre><code>#!c:/Python27/python.exe -u

server_ip = '127.0.0.1'
</code></pre>

<p><strong>connection.py</strong></p>

<pre><code>import globals

class Connection:        
    def __init__(self, server_ip = globals.server_ip):
        print 'Connection is ' + server_ip + '\n'
</code></pre>

<p>I was expecting I will be getting <code>Connection is 192.168.0.1</code> being printed. But, instead, <code>Connection is 127.0.0.1</code> is being printed.</p>

<p>Unless I try to construct the connection by passing in the parameter explicitly (which is not something I wish to, as I am reluctant to make change any more on Connection with 0 parameter)</p>

<p><code>connection = Connection(globals.server_ip)</code></p>

<p>Why is this so? Is there any other techniques I can apply?</p>
