Python URI-Template library
Switch branches/tags
Nothing to show
Latest commit 504b9bd Aug 19, 2008 @jacobian jacobian Updated README.
Failed to load latest commit information.
.hgtags Added tag release-1.0 for changeset 12ef4cff18ab Jan 29, 2008
LICENSE Initial revision. Jan 8, 2008
MANIFEST Added missing files from last commit Jan 29, 2008
README Added missing files from last commit Jan 29, 2008



A library for simple URI handling. It has no external dependancies, and works
with Python 2.3+.

Currently contains only an implementation of URI-Templates
( -- but see the TODO_ below.

Some bits are inspired by or based on:

    * Joe Gregorio's example implementation

    * Addressable (


Simple usage::

    >>> import uri
    >>> args = {'foo': 'it worked'}
    >>> uri.expand_template("{foo}", args)

    >>> args = {'a':'foo', 'b':'bar', 'a_b':'baz'}
    >>> uri.expand_template("{a}{b}/{a_b}", args)
You can also use keyword arguments for a more pythonic style::
    >>> uri.expand_template("{a}", a="foo")


I use GitHub; the canonical repository lives at Please feel free to send pull requests or
patches to <>


Over time, I'd like to add the following features to this library:

    * ``uri.extract(template, uri)``: extract a dict of info given a template
      and a URI.
    * ``uri.parse(uri)``: thin wrapper around ``urlparse.urlparse()`` that
      returns a class (so you can do e.g. ``some_uri.fragment`` or whathaveyou.)
      This URI class should have expand/extract methods.
    * Add methods/functions to do sane URI joining -- ``urlparse.urljoin`` 
      *never* does what I think it's going to do, especially when faced
      with relative URIs.