The examples we have seen so far talk about absolute URIs, but there are relative URI references too. A relative reference is one that lacks, at least, the scheme. There are three types of relative references: network paths, absolute paths, and relative paths:
Network paths only lack the scheme, they start by a double slash and the authority, followed by the absolute path. They are rarely used.
//www.ietf.org/rfc/rfc2396.txt
The absolute paths lack both the scheme and the authority. They start by a slash.
/rfc/rfc2396.txt
Relative paths lack the first slash of absolute paths. They can start by the special segment ".", or by one or more "..". Examples are:
rfc/rfc2396.txt
./rfc/rfc2396.txt
../rfc2616.txt
The most common operation with relative references is to resolve them. That is to say, to obtain (with the help of a base reference) the absolute reference that identifies our resource. This is achieved with the resolve method:
>>> base = get_reference('http://www.ietf.org/rfc/rfc2615.txt')
>>> print base.resolve('//www.ietf.org/rfc/rfc2396.txt')
http://www.ietf.org/rfc/rfc2396.txt
>>> print base.resolve('/rfc/rfc2396.txt')
http://www.ietf.org/rfc/rfc2396.txt
>>> print base.resolve('rfc2396.txt')
http://www.ietf.org/rfc/rfc2396.txt