title: How can we simulate pass by reference in python?
body: <p>Let's say we have a function <code>foo()</code></p>
  
  <pre><code>def foo():
    foo.a = 2
  
  foo.a = 1
  foo()
  
  &gt;&gt; foo.a
  &gt;&gt; 2
  </code></pre>
  
  <p>Is this pythonic or should I wrap the variable in mutable objects such as a list?</p>
  
  <p>Eg:</p>
  
  <pre><code>a = [1]
  
  def foo(a):
    a[0] = 2
  foo()
  
  &gt;&gt; a
  
  &gt;&gt; 2
  </code></pre>