def join(*parts):
try:<EOL><INDENT>path = [parts[<NUM_LIT:0>]]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>for p in parts[<NUM_LIT:1>:]:<EOL><INDENT>path[-<NUM_LIT:1>] = path[-<NUM_LIT:1>].rstrip("<STR_LIT:/>")<EOL>full = isfull(path[<NUM_LIT:0>])<EOL>if isfull(p) or (isabs(p) and not full):<EOL><INDENT>path = [p]<EOL><DEDENT>else:<EOL><INDENT>path.append(p.lstrip('<STR_LIT:/>'))<EOL><DEDENT><DEDENT>return "<STR_LIT:/>".join(path)<EOL>
Join path name components, inserting ``/`` as needed.

If any component is an absolute path (see :func:`isabs`), all
previous components will be discarded.  However, full URIs (see
:func:`isfull`) take precedence over incomplete ones:

.. code-block:: python

  >>> import pydoop.hdfs.path as hpath
  >>> hpath.join('bar', '/foo')
  '/foo'
  >>> hpath.join('hdfs://host:1/', '/foo')
  'hdfs://host:1/foo'

Note that this is *not* the reverse of :func:`split`, but rather a
specialized version of :func:`os.path.join`. No check is made to determine
whether the returned string is a valid HDFS path.