title: Why do list operations in python operate outside of the function scope?
body: <p>In the python code below, variable <code>number</code> is passed to the function <code>addone</code>, and a local copy is operated on. The value of number stays the same.</p>
  
  <pre><code>def addone(num):
      num = num + 1
      print "function: added 1, now %d" % num
  
  number = 5
  print "Before:", number
  addone(number)
  print "After:", number
  </code></pre>
  
  <p>Output :</p>
  
  <pre><code>Before: 5
  function: added 1, now 6
  After: 5
  </code></pre>
  
  <p>However, the behavior appears to be different with list operations like pop, append etc. This somewhat confuses me. Do all list operations operate globally ? If so, is there any particular reason behind it ?</p>
  
  <pre><code>def pop_first(stuff):
      popped = stuff.pop(0)
      print "function: '%s' was popped!" % popped
  
  words = ["A", "list", "of", "words"]
  print "Before:", words
  pop_first(words)
  print "After:", words
  </code></pre>
  
  <p>Output :</p>
  
  <pre><code>Before: ['A', 'list', 'of', 'words']
  function: 'A' was popped!
  After: ['list', 'of', 'words']
  </code></pre>