title: Why does os.path.join throw away arguments?
body: <p>I'm learning Python and I noticed something strange with one of my scripts.  Doing a little testing I discovered the problem stemmed from this behavior:</p>
  
  <pre><code>&gt;&gt;&gt; import os
  &gt;&gt;&gt; os.path.join('a','b')
  'a/b'
  &gt;&gt;&gt; os.path.join('a','/b')
  '/b'
  </code></pre>
  
  <p>Checking the <a href="http://docs.python.org/library/os.path.html#module-os.path" rel="nofollow noreferrer">documentation</a>, this is, in fact, the design of the function:</p>
  
  <blockquote>
    <p>os.path.<strong>join</strong>(<em>path1</em><strong>[</strong>, <em>path2</em><strong>[</strong>, ...<strong>]]</strong>)</p>
    
    <blockquote>
      <p>Join one or more path components intelligently. If any component is an absolute path, all previous components (on Windows, including the previous drive letter, if there was one) are thrown away, and joining continues. ...</p>
    </blockquote>
  </blockquote>
  
  <p>My question isn't <a href="https://stackoverflow.com/q/11873787/1438">why my script failed</a>, but rather why the function was designed this way.  I mean, on Unix at least, <code>a//b</code> is a perfectly acceptable way to designate a path, if not elegant.  Why was the function designed this way?  Is there any way to tell if one or more path elements have been discarded short of testing each path string with <code>os.path.isabs()</code>?</p>
  
  <hr>
  
  <p>Out of curiosity, I also checked the case where a path component ends in an <code>os.sep</code> character:</p>
  
  <pre><code>&gt;&gt;&gt; os.path.join('a/','b')
  'a/b'
  </code></pre>
  
  <p>That works as expected.</p>