title: Default empty lists vs. *args in Python
body: <p>I have a function (which I'll call foo) that modifies a list (which I'll call my_list). foo does not always want to modify my_list in the same way; its behavior should influenced by its other arguments (which I'll call other_inputs). Here's some pseudocode:</p>
  
  <pre><code>def foo(my_list, other_inputs):
      for input in other_inputs:
          my_list.bar(input)
      return my_list
  </code></pre>
  
  <p>I can see two ways to format other_inputs. </p>
  
  <p>I could use *args:</p>
  
  <pre><code>def foo(my_list, *other_inputs):
      for input in other_inputs:
          my_list.bar(input)
      return my_list
  </code></pre>
  
  <p>Alternately, I could make other_inputs a list, empty by default:</p>
  
  <pre><code>def foo(my_list, other_inputs=[]):
      for input in other_inputs:
          my_list.bar(input)
      return my_list
  </code></pre>
  
  <p>I've tested it on my machine and both options seem to do the same thing. Which one is preferable?</p>
  
  <p>(Assume that this foo() is called many times, each time with a new other_inputs read in from some external source. Also assume that other_inputs is never appended to or mutated in any other way between external reads, so <a href="https://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument?lq=1">this</a> isn't a problem.)</p>