Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 1 | :mod:`urllib.parse` --- Parse URLs into components |
| 2 | ================================================== |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 3 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 4 | .. module:: urllib.parse |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 5 | :synopsis: Parse URLs into or assemble them from components. |
| 6 | |
| 7 | |
| 8 | .. index:: |
| 9 | single: WWW |
| 10 | single: World Wide Web |
| 11 | single: URL |
| 12 | pair: URL; parsing |
| 13 | pair: relative; URL |
| 14 | |
| 15 | This module defines a standard interface to break Uniform Resource Locator (URL) |
| 16 | strings up in components (addressing scheme, network location, path etc.), to |
| 17 | combine the components back into a URL string, and to convert a "relative URL" |
| 18 | to an absolute URL given a "base URL." |
| 19 | |
| 20 | The module has been designed to match the Internet RFC on Relative Uniform |
| 21 | Resource Locators (and discovered a bug in an earlier draft!). It supports the |
| 22 | following URL schemes: ``file``, ``ftp``, ``gopher``, ``hdl``, ``http``, |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 23 | ``https``, ``imap``, ``mailto``, ``mms``, ``news``, ``nntp``, ``prospero``, |
| 24 | ``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``, |
| 25 | ``snews``, ``svn``, ``svn+ssh``, ``telnet``, ``wais``. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 26 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 27 | The :mod:`urllib.parse` module defines the following functions: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 28 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 29 | .. function:: urlparse(urlstring[, default_scheme[, allow_fragments]]) |
| 30 | |
| 31 | Parse a URL into six components, returning a 6-tuple. This corresponds to the |
| 32 | general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. |
| 33 | Each tuple item is a string, possibly empty. The components are not broken up in |
| 34 | smaller parts (for example, the network location is a single string), and % |
| 35 | escapes are not expanded. The delimiters as shown above are not part of the |
| 36 | result, except for a leading slash in the *path* component, which is retained if |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 37 | present. For example: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 38 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 39 | >>> from urllib.parse import urlparse |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 40 | >>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 41 | >>> o # doctest: +NORMALIZE_WHITESPACE |
| 42 | ParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', |
| 43 | params='', query='', fragment='') |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 44 | >>> o.scheme |
| 45 | 'http' |
| 46 | >>> o.port |
| 47 | 80 |
| 48 | >>> o.geturl() |
| 49 | 'http://www.cwi.nl:80/%7Eguido/Python.html' |
| 50 | |
| 51 | If the *default_scheme* argument is specified, it gives the default addressing |
| 52 | scheme, to be used only if the URL does not specify one. The default value for |
| 53 | this argument is the empty string. |
| 54 | |
| 55 | If the *allow_fragments* argument is false, fragment identifiers are not |
| 56 | allowed, even if the URL's addressing scheme normally does support them. The |
| 57 | default value for this argument is :const:`True`. |
| 58 | |
| 59 | The return value is actually an instance of a subclass of :class:`tuple`. This |
| 60 | class has the following additional read-only convenience attributes: |
| 61 | |
| 62 | +------------------+-------+--------------------------+----------------------+ |
| 63 | | Attribute | Index | Value | Value if not present | |
| 64 | +==================+=======+==========================+======================+ |
| 65 | | :attr:`scheme` | 0 | URL scheme specifier | empty string | |
| 66 | +------------------+-------+--------------------------+----------------------+ |
| 67 | | :attr:`netloc` | 1 | Network location part | empty string | |
| 68 | +------------------+-------+--------------------------+----------------------+ |
| 69 | | :attr:`path` | 2 | Hierarchical path | empty string | |
| 70 | +------------------+-------+--------------------------+----------------------+ |
| 71 | | :attr:`params` | 3 | Parameters for last path | empty string | |
| 72 | | | | element | | |
| 73 | +------------------+-------+--------------------------+----------------------+ |
| 74 | | :attr:`query` | 4 | Query component | empty string | |
| 75 | +------------------+-------+--------------------------+----------------------+ |
| 76 | | :attr:`fragment` | 5 | Fragment identifier | empty string | |
| 77 | +------------------+-------+--------------------------+----------------------+ |
| 78 | | :attr:`username` | | User name | :const:`None` | |
| 79 | +------------------+-------+--------------------------+----------------------+ |
| 80 | | :attr:`password` | | Password | :const:`None` | |
| 81 | +------------------+-------+--------------------------+----------------------+ |
| 82 | | :attr:`hostname` | | Host name (lower case) | :const:`None` | |
| 83 | +------------------+-------+--------------------------+----------------------+ |
| 84 | | :attr:`port` | | Port number as integer, | :const:`None` | |
| 85 | | | | if present | | |
| 86 | +------------------+-------+--------------------------+----------------------+ |
| 87 | |
| 88 | See section :ref:`urlparse-result-object` for more information on the result |
| 89 | object. |
| 90 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 91 | |
| 92 | .. function:: urlunparse(parts) |
| 93 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 94 | Construct a URL from a tuple as returned by ``urlparse()``. The *parts* |
| 95 | argument can be any six-item iterable. This may result in a slightly |
| 96 | different, but equivalent URL, if the URL that was parsed originally had |
| 97 | unnecessary delimiters (for example, a ``?`` with an empty query; the RFC |
| 98 | states that these are equivalent). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 99 | |
| 100 | |
| 101 | .. function:: urlsplit(urlstring[, default_scheme[, allow_fragments]]) |
| 102 | |
| 103 | This is similar to :func:`urlparse`, but does not split the params from the URL. |
| 104 | This should generally be used instead of :func:`urlparse` if the more recent URL |
| 105 | syntax allowing parameters to be applied to each segment of the *path* portion |
| 106 | of the URL (see :rfc:`2396`) is wanted. A separate function is needed to |
| 107 | separate the path segments and parameters. This function returns a 5-tuple: |
| 108 | (addressing scheme, network location, path, query, fragment identifier). |
| 109 | |
| 110 | The return value is actually an instance of a subclass of :class:`tuple`. This |
| 111 | class has the following additional read-only convenience attributes: |
| 112 | |
| 113 | +------------------+-------+-------------------------+----------------------+ |
| 114 | | Attribute | Index | Value | Value if not present | |
| 115 | +==================+=======+=========================+======================+ |
| 116 | | :attr:`scheme` | 0 | URL scheme specifier | empty string | |
| 117 | +------------------+-------+-------------------------+----------------------+ |
| 118 | | :attr:`netloc` | 1 | Network location part | empty string | |
| 119 | +------------------+-------+-------------------------+----------------------+ |
| 120 | | :attr:`path` | 2 | Hierarchical path | empty string | |
| 121 | +------------------+-------+-------------------------+----------------------+ |
| 122 | | :attr:`query` | 3 | Query component | empty string | |
| 123 | +------------------+-------+-------------------------+----------------------+ |
| 124 | | :attr:`fragment` | 4 | Fragment identifier | empty string | |
| 125 | +------------------+-------+-------------------------+----------------------+ |
| 126 | | :attr:`username` | | User name | :const:`None` | |
| 127 | +------------------+-------+-------------------------+----------------------+ |
| 128 | | :attr:`password` | | Password | :const:`None` | |
| 129 | +------------------+-------+-------------------------+----------------------+ |
| 130 | | :attr:`hostname` | | Host name (lower case) | :const:`None` | |
| 131 | +------------------+-------+-------------------------+----------------------+ |
| 132 | | :attr:`port` | | Port number as integer, | :const:`None` | |
| 133 | | | | if present | | |
| 134 | +------------------+-------+-------------------------+----------------------+ |
| 135 | |
| 136 | See section :ref:`urlparse-result-object` for more information on the result |
| 137 | object. |
| 138 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 139 | |
| 140 | .. function:: urlunsplit(parts) |
| 141 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 142 | Combine the elements of a tuple as returned by :func:`urlsplit` into a |
| 143 | complete URL as a string. The *parts* argument can be any five-item |
| 144 | iterable. This may result in a slightly different, but equivalent URL, if the |
| 145 | URL that was parsed originally had unnecessary delimiters (for example, a ? |
| 146 | with an empty query; the RFC states that these are equivalent). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 147 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 148 | |
| 149 | .. function:: urljoin(base, url[, allow_fragments]) |
| 150 | |
| 151 | Construct a full ("absolute") URL by combining a "base URL" (*base*) with |
| 152 | another URL (*url*). Informally, this uses components of the base URL, in |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 153 | particular the addressing scheme, the network location and (part of) the |
| 154 | path, to provide missing components in the relative URL. For example: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 155 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 156 | >>> from urllib.parse import urljoin |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 157 | >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html') |
| 158 | 'http://www.cwi.nl/%7Eguido/FAQ.html' |
| 159 | |
| 160 | The *allow_fragments* argument has the same meaning and default as for |
| 161 | :func:`urlparse`. |
| 162 | |
| 163 | .. note:: |
| 164 | |
| 165 | If *url* is an absolute URL (that is, starting with ``//`` or ``scheme://``), |
| 166 | the *url*'s host name and/or scheme will be present in the result. For example: |
| 167 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 168 | .. doctest:: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 169 | |
| 170 | >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', |
| 171 | ... '//www.python.org/%7Eguido') |
| 172 | 'http://www.python.org/%7Eguido' |
| 173 | |
| 174 | If you do not want that behavior, preprocess the *url* with :func:`urlsplit` and |
| 175 | :func:`urlunsplit`, removing possible *scheme* and *netloc* parts. |
| 176 | |
| 177 | |
| 178 | .. function:: urldefrag(url) |
| 179 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 180 | If *url* contains a fragment identifier, return a modified version of *url* |
| 181 | with no fragment identifier, and the fragment identifier as a separate |
| 182 | string. If there is no fragment identifier in *url*, return *url* unmodified |
| 183 | and an empty string. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 184 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 185 | .. function:: quote(string[, safe[, encoding[, errors]]]) |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 186 | |
| 187 | Replace special characters in *string* using the ``%xx`` escape. Letters, |
| 188 | digits, and the characters ``'_.-'`` are never quoted. The optional *safe* |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 189 | parameter specifies additional ASCII characters that should not be quoted |
| 190 | --- its default value is ``'/'``. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 191 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 192 | *string* may be either a :class:`str` or a :class:`bytes`. |
| 193 | |
| 194 | The optional *encoding* and *errors* parameters specify how to deal with |
| 195 | non-ASCII characters, as accepted by the :meth:`str.encode` method. |
| 196 | *encoding* defaults to ``'utf-8'``. |
| 197 | *errors* defaults to ``'strict'``, meaning unsupported characters raise a |
| 198 | :class:`UnicodeEncodeError`. |
| 199 | *encoding* and *errors* must not be supplied if *string* is a |
| 200 | :class:`bytes`, or a :class:`TypeError` is raised. |
| 201 | |
| 202 | Note that ``quote(string, safe, encoding, errors)`` is equivalent to |
| 203 | ``quote_from_bytes(string.encode(encoding, errors), safe)``. |
| 204 | |
| 205 | Example: ``quote('/El Niño/')`` yields ``'/El%20Ni%C3%B1o/'``. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 206 | |
| 207 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 208 | .. function:: quote_plus(string[, safe[, encoding[, errors]]]) |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 209 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 210 | Like :func:`quote`, but also replace spaces by plus signs, as required for |
| 211 | quoting HTML form values. Plus signs in the original string are escaped |
| 212 | unless they are included in *safe*. It also does not have *safe* default to |
| 213 | ``'/'``. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 214 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 215 | Example: ``quote_plus('/El Niño/')`` yields ``'%2FEl+Ni%C3%B1o%2F'``. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 216 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 217 | .. function:: quote_from_bytes(bytes[, safe]) |
| 218 | |
| 219 | Like :func:`quote`, but accepts a :class:`bytes` object rather than a |
| 220 | :class:`str`, and does not perform string-to-bytes encoding. |
| 221 | |
| 222 | Example: ``quote_from_bytes(b'a&\xef')`` yields |
| 223 | ``'a%26%EF'``. |
| 224 | |
| 225 | .. function:: unquote(string[, encoding[, errors]]) |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 226 | |
| 227 | Replace ``%xx`` escapes by their single-character equivalent. |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 228 | The optional *encoding* and *errors* parameters specify how to decode |
| 229 | percent-encoded sequences into Unicode characters, as accepted by the |
| 230 | :meth:`bytes.decode` method. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 231 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 232 | *string* must be a :class:`str`. |
| 233 | |
| 234 | *encoding* defaults to ``'utf-8'``. |
| 235 | *errors* defaults to ``'replace'``, meaning invalid sequences are replaced |
| 236 | by a placeholder character. |
| 237 | |
| 238 | Example: ``unquote('/El%20Ni%C3%B1o/')`` yields ``'/El Niño/'``. |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 239 | |
| 240 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 241 | .. function:: unquote_plus(string[, encoding[, errors]]) |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 242 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 243 | Like :func:`unquote`, but also replace plus signs by spaces, as required for |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 244 | unquoting HTML form values. |
| 245 | |
Guido van Rossum | 52dbbb9 | 2008-08-18 21:44:30 +0000 | [diff] [blame] | 246 | *string* must be a :class:`str`. |
| 247 | |
| 248 | Example: ``unquote_plus('/El+Ni%C3%B1o/')`` yields ``'/El Niño/'``. |
| 249 | |
| 250 | .. function:: unquote_to_bytes(string) |
| 251 | |
| 252 | Replace ``%xx`` escapes by their single-octet equivalent, and return a |
| 253 | :class:`bytes` object. |
| 254 | |
| 255 | *string* may be either a :class:`str` or a :class:`bytes`. |
| 256 | |
| 257 | If it is a :class:`str`, unescaped non-ASCII characters in *string* |
| 258 | are encoded into UTF-8 bytes. |
| 259 | |
| 260 | Example: ``unquote_to_bytes('a%26%EF')`` yields |
| 261 | ``b'a&\xef'``. |
| 262 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 263 | |
| 264 | .. function:: urlencode(query[, doseq]) |
| 265 | |
| 266 | Convert a mapping object or a sequence of two-element tuples to a "url-encoded" |
| 267 | string, suitable to pass to :func:`urlopen` above as the optional *data* |
| 268 | argument. This is useful to pass a dictionary of form fields to a ``POST`` |
| 269 | request. The resulting string is a series of ``key=value`` pairs separated by |
| 270 | ``'&'`` characters, where both *key* and *value* are quoted using |
| 271 | :func:`quote_plus` above. If the optional parameter *doseq* is present and |
| 272 | evaluates to true, individual ``key=value`` pairs are generated for each element |
| 273 | of the sequence. When a sequence of two-element tuples is used as the *query* |
| 274 | argument, the first element of each tuple is a key and the second is a value. |
| 275 | The order of parameters in the encoded string will match the order of parameter |
| 276 | tuples in the sequence. The :mod:`cgi` module provides the functions |
| 277 | :func:`parse_qs` and :func:`parse_qsl` which are used to parse query strings |
| 278 | into Python data structures. |
| 279 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 280 | |
| 281 | .. seealso:: |
| 282 | |
| 283 | :rfc:`1738` - Uniform Resource Locators (URL) |
| 284 | This specifies the formal syntax and semantics of absolute URLs. |
| 285 | |
| 286 | :rfc:`1808` - Relative Uniform Resource Locators |
| 287 | This Request For Comments includes the rules for joining an absolute and a |
| 288 | relative URL, including a fair number of "Abnormal Examples" which govern the |
| 289 | treatment of border cases. |
| 290 | |
| 291 | :rfc:`2396` - Uniform Resource Identifiers (URI): Generic Syntax |
| 292 | Document describing the generic syntactic requirements for both Uniform Resource |
| 293 | Names (URNs) and Uniform Resource Locators (URLs). |
| 294 | |
| 295 | |
| 296 | .. _urlparse-result-object: |
| 297 | |
| 298 | Results of :func:`urlparse` and :func:`urlsplit` |
| 299 | ------------------------------------------------ |
| 300 | |
| 301 | The result objects from the :func:`urlparse` and :func:`urlsplit` functions are |
| 302 | subclasses of the :class:`tuple` type. These subclasses add the attributes |
| 303 | described in those functions, as well as provide an additional method: |
| 304 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 305 | .. method:: ParseResult.geturl() |
| 306 | |
| 307 | Return the re-combined version of the original URL as a string. This may differ |
| 308 | from the original URL in that the scheme will always be normalized to lower case |
| 309 | and empty components may be dropped. Specifically, empty parameters, queries, |
| 310 | and fragment identifiers will be removed. |
| 311 | |
| 312 | The result of this method is a fixpoint if passed back through the original |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 313 | parsing function: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 314 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 315 | >>> import urllib.parse |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 316 | >>> url = 'HTTP://www.Python.org/doc/#' |
| 317 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 318 | >>> r1 = urllib.parse.urlsplit(url) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 319 | >>> r1.geturl() |
| 320 | 'http://www.Python.org/doc/' |
| 321 | |
Senthil Kumaran | aca8fd7 | 2008-06-23 04:41:59 +0000 | [diff] [blame] | 322 | >>> r2 = urllib.parse.urlsplit(r1.geturl()) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 323 | >>> r2.geturl() |
| 324 | 'http://www.Python.org/doc/' |
| 325 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 326 | |
| 327 | The following classes provide the implementations of the parse results:: |
| 328 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 329 | .. class:: BaseResult |
| 330 | |
Georg Brandl | 0f7ede4 | 2008-06-23 11:23:31 +0000 | [diff] [blame] | 331 | Base class for the concrete result classes. This provides most of the |
| 332 | attribute definitions. It does not provide a :meth:`geturl` method. It is |
| 333 | derived from :class:`tuple`, but does not override the :meth:`__init__` or |
| 334 | :meth:`__new__` methods. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 335 | |
| 336 | |
| 337 | .. class:: ParseResult(scheme, netloc, path, params, query, fragment) |
| 338 | |
| 339 | Concrete class for :func:`urlparse` results. The :meth:`__new__` method is |
| 340 | overridden to support checking that the right number of arguments are passed. |
| 341 | |
| 342 | |
| 343 | .. class:: SplitResult(scheme, netloc, path, query, fragment) |
| 344 | |
| 345 | Concrete class for :func:`urlsplit` results. The :meth:`__new__` method is |
| 346 | overridden to support checking that the right number of arguments are passed. |
| 347 | |