18.17.1 Results of urlparse() and urlsplit()

The result objects from the urlparse() and urlsplit() functions are subclasses of the tuple type. These subclasses add the attributes described in those functions, as well as provide an additional method:

geturl( )
Return the re-combined version of the original URL as a string. This may differ from the original URL in that the scheme will always be normalized to lower case and empty components may be dropped. Specifically, empty parameters, queries, and fragment identifiers will be removed.

The result of this method is a fixpoint if passed back through the original parsing function:

>>> import urlparse
>>> url = 'HTTP://www.Python.org/doc/#'

>>> r1 = urlparse.urlsplit(url)
>>> r1.geturl()
'http://www.Python.org/doc/'

>>> r2 = urlparse.urlsplit(r1.geturl())
>>> r2.geturl()
'http://www.Python.org/doc/'

New in version 2.5.

The following classes provide the implementations of the parse results::

class BaseResult
Base class for the concrete result classes. This provides most of the attribute definitions. It does not provide a geturl() method. It is derived from tuple, but does not override the __init__() or __new__() methods.

class ParseResult( scheme, netloc, path, params, query, fragment)
Concrete class for urlparse() results. The __new__() method is overridden to support checking that the right number of arguments are passed.

class SplitResult( scheme, netloc, path, query, fragment)
Concrete class for urlsplit() results. The __new__() method is overridden to support checking that the right number of arguments are passed.
See About this document... for information on suggesting changes.