How to change variable value in other module?
<p>I have the following modules:</p>

<p><strong>test.py</strong></p>

<pre><code>import test1


var1 = 'Test1'
var2 = 'Test2'

print var1
print var2

test1.modify_vars(var1, var2)

print var1
print var2
</code></pre>

<p>and the module </p>

<p><strong>test1.py</strong></p>

<pre><code>def modify_vars(var1, var2):
    var1 += '_changed'
    var2 += '_changed'
</code></pre>

<p>I am expecting to get the following output:</p>

<pre><code>Test1
Test2
Test1_changed
Test2_changed
</code></pre>

<p>I will get:</p>

<pre><code>Test1
Test2
Test1 
Test2
</code></pre>

<p>It is mandatory to avoid importing test module in test1 module.</p>

<p>How to achieve this without returning values from the method ? (sort of reference passing)</p>

<p>Strings are immutable. You cannot do what you want. Using <code>+=</code> with a string will always return a new string, which will have nothing to do with whatever <code>var1</code> and <code>var2</code> are assigned to.</p>

<p>The only way to achieve something close to what you want (and, to be honest, you should probably change your requirements) is to use a list rather than separate variables, and modify its contents:</p>

<pre><code>var = ['Test1', 'Test2']
...

def modify_var(var):
    var[0] += '_changed'
    var[1] += '_changed'
</code></pre>

python