title: Why use sys.path.append(path) instead of sys.path.insert(1, path)?
body: <p><strong>Edit:</strong> based on a Ulf Rompe's comment, <strong>it is important you use "1" instead of "0"</strong>, otherwise you will break <a href="http://docs.python.org/library/sys.html#sys.path">sys.path</a>.</p>
  
  <p>I have been doing python for quite a while now (over a year), and I am always confused as to why people recommend you use <code>sys.path.append()</code> instead of <code>sys.path.insert()</code>.  Let me demonstrate.</p>
  
  <p>Let's say I am working on a module named PyWorkbooks (that is installed on my computer), but I am simultaneously working on a different module (let's say PyJob) that incorporates PyWorkbooks.  As I'm working on PyJob I find errors in PyWorkbooks that I am correcting, so I would like to import a development version.</p>
  
  <p>There are multiple ways to work on both (I could put my PyWorkbooks project inside of PyJob, for instance), but sometimes I will still need to play with the path.  However, <strong>I cannot simply do a <code>sys.path.append()</code> to the folder where PyWorkbooks is at</strong>.  Why?  Because python will find my installed PyWorkbooks first!</p>
  
  <p>This is why you have to do a sys.path.insert(1, path_to_dev_pyworkbooks)</p>
  
  <p>In summary:</p>
  
  <pre><code>sys.path.append(path_to_dev_pyworkbooks)
  import PyWorkbooks # does NOT import dev pyworkbooks, imports installed one
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>sys.path.insert(1, path_to_dev_pyworkbooks) # based on comments you should use **1 not 0**
  import PyWorkbooks # imports correct file
  </code></pre>
  
  <p>This has caused a few hangups for me in the past, and I would really like it if we (as a community) started recommending <code>sys.path.insert(1, path)</code>, as if you are manually inserting a path I think it is safe to say that that is the path you want to use!</p>
  
  <p>Or do I have something wrong?  It's a question that sometimes bothers me and I wanted it in the open!</p>