blob: 36fe1b31b544f24d4d24862effeb3721a5b3838c [file] [log] [blame]
Senthil Kumaranaca8fd72008-06-23 04:41:59 +00001:mod:`urllib.parse` --- Parse URLs into components
2==================================================
Georg Brandl116aa622007-08-15 14:28:22 +00003
Senthil Kumaranaca8fd72008-06-23 04:41:59 +00004.. module:: urllib.parse
Georg Brandl116aa622007-08-15 14:28:22 +00005 :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
15This module defines a standard interface to break Uniform Resource Locator (URL)
16strings up in components (addressing scheme, network location, path etc.), to
17combine the components back into a URL string, and to convert a "relative URL"
18to an absolute URL given a "base URL."
19
20The module has been designed to match the Internet RFC on Relative Uniform
21Resource Locators (and discovered a bug in an earlier draft!). It supports the
22following URL schemes: ``file``, ``ftp``, ``gopher``, ``hdl``, ``http``,
Georg Brandl0f7ede42008-06-23 11:23:31 +000023``https``, ``imap``, ``mailto``, ``mms``, ``news``, ``nntp``, ``prospero``,
24``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``,
25``snews``, ``svn``, ``svn+ssh``, ``telnet``, ``wais``.
Georg Brandl116aa622007-08-15 14:28:22 +000026
Senthil Kumaranaca8fd72008-06-23 04:41:59 +000027The :mod:`urllib.parse` module defines the following functions:
Georg Brandl116aa622007-08-15 14:28:22 +000028
R. David Murray341fe912010-05-25 15:54:24 +000029.. function:: urlparse(urlstring, scheme='', allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +000030
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 Heimesfe337bf2008-03-23 21:54:12 +000037 present. For example:
Georg Brandl116aa622007-08-15 14:28:22 +000038
Senthil Kumaranaca8fd72008-06-23 04:41:59 +000039 >>> from urllib.parse import urlparse
Georg Brandl116aa622007-08-15 14:28:22 +000040 >>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html')
Christian Heimesfe337bf2008-03-23 21:54:12 +000041 >>> o # doctest: +NORMALIZE_WHITESPACE
42 ParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
43 params='', query='', fragment='')
Georg Brandl116aa622007-08-15 14:28:22 +000044 >>> o.scheme
45 'http'
46 >>> o.port
47 80
48 >>> o.geturl()
49 'http://www.cwi.nl:80/%7Eguido/Python.html'
50
Senthil Kumarane4be7212010-11-07 13:07:14 +000051 Following the syntax specifications in :rfc:`1808`, urlparse recognizes
52 a netloc only if it is properly introduced by '//'. Otherwise the
53 input is presumed to be a relative URL and thus to start with
54 a path component.
Senthil Kumaran8801f7a2010-08-04 04:53:07 +000055
Senthil Kumaranfe9230a2011-06-19 13:52:49 -070056 >>> from urllib.parse import urlparse
Senthil Kumaran8801f7a2010-08-04 04:53:07 +000057 >>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
58 ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
59 params='', query='', fragment='')
60 >>> urlparse('www.cwi.nl:80/%7Eguido/Python.html')
61 ParseResult(scheme='', netloc='', path='www.cwi.nl:80/%7Eguido/Python.html',
62 params='', query='', fragment='')
63 >>> urlparse('help/Python.html')
64 ParseResult(scheme='', netloc='', path='help/Python.html', params='',
65 query='', fragment='')
66
R. David Murray341fe912010-05-25 15:54:24 +000067 If the *scheme* argument is specified, it gives the default addressing
Georg Brandl116aa622007-08-15 14:28:22 +000068 scheme, to be used only if the URL does not specify one. The default value for
69 this argument is the empty string.
70
71 If the *allow_fragments* argument is false, fragment identifiers are not
72 allowed, even if the URL's addressing scheme normally does support them. The
73 default value for this argument is :const:`True`.
74
75 The return value is actually an instance of a subclass of :class:`tuple`. This
76 class has the following additional read-only convenience attributes:
77
78 +------------------+-------+--------------------------+----------------------+
79 | Attribute | Index | Value | Value if not present |
80 +==================+=======+==========================+======================+
81 | :attr:`scheme` | 0 | URL scheme specifier | empty string |
82 +------------------+-------+--------------------------+----------------------+
83 | :attr:`netloc` | 1 | Network location part | empty string |
84 +------------------+-------+--------------------------+----------------------+
85 | :attr:`path` | 2 | Hierarchical path | empty string |
86 +------------------+-------+--------------------------+----------------------+
87 | :attr:`params` | 3 | Parameters for last path | empty string |
88 | | | element | |
89 +------------------+-------+--------------------------+----------------------+
90 | :attr:`query` | 4 | Query component | empty string |
91 +------------------+-------+--------------------------+----------------------+
92 | :attr:`fragment` | 5 | Fragment identifier | empty string |
93 +------------------+-------+--------------------------+----------------------+
94 | :attr:`username` | | User name | :const:`None` |
95 +------------------+-------+--------------------------+----------------------+
96 | :attr:`password` | | Password | :const:`None` |
97 +------------------+-------+--------------------------+----------------------+
98 | :attr:`hostname` | | Host name (lower case) | :const:`None` |
99 +------------------+-------+--------------------------+----------------------+
100 | :attr:`port` | | Port number as integer, | :const:`None` |
101 | | | if present | |
102 +------------------+-------+--------------------------+----------------------+
103
104 See section :ref:`urlparse-result-object` for more information on the result
105 object.
106
Georg Brandl116aa622007-08-15 14:28:22 +0000107
Georg Brandlb044b2a2009-09-16 16:05:59 +0000108.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000109
110 Parse a query string given as a string argument (data of type
111 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a
112 dictionary. The dictionary keys are the unique query variable names and the
113 values are lists of values for each name.
114
115 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranea54b032010-08-09 20:05:35 +0000116 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000117 indicates that blanks should be retained as blank strings. The default false
118 value indicates that blank values are to be ignored and treated as if they were
119 not included.
120
121 The optional argument *strict_parsing* is a flag indicating what to do with
122 parsing errors. If false (the default), errors are silently ignored. If true,
123 errors raise a :exc:`ValueError` exception.
124
Georg Brandl7fe2c4a2008-12-05 07:32:56 +0000125 Use the :func:`urllib.parse.urlencode` function to convert such
126 dictionaries into query strings.
Facundo Batistac469d4c2008-09-03 22:49:01 +0000127
128
Georg Brandlb044b2a2009-09-16 16:05:59 +0000129.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000130
131 Parse a query string given as a string argument (data of type
132 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of
133 name, value pairs.
134
135 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranea54b032010-08-09 20:05:35 +0000136 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000137 indicates that blanks should be retained as blank strings. The default false
138 value indicates that blank values are to be ignored and treated as if they were
139 not included.
140
141 The optional argument *strict_parsing* is a flag indicating what to do with
142 parsing errors. If false (the default), errors are silently ignored. If true,
143 errors raise a :exc:`ValueError` exception.
144
145 Use the :func:`urllib.parse.urlencode` function to convert such lists of pairs into
146 query strings.
147
148
Georg Brandl116aa622007-08-15 14:28:22 +0000149.. function:: urlunparse(parts)
150
Georg Brandl0f7ede42008-06-23 11:23:31 +0000151 Construct a URL from a tuple as returned by ``urlparse()``. The *parts*
152 argument can be any six-item iterable. This may result in a slightly
153 different, but equivalent URL, if the URL that was parsed originally had
154 unnecessary delimiters (for example, a ``?`` with an empty query; the RFC
155 states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000156
157
R. David Murray341fe912010-05-25 15:54:24 +0000158.. function:: urlsplit(urlstring, scheme='', allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000159
160 This is similar to :func:`urlparse`, but does not split the params from the URL.
161 This should generally be used instead of :func:`urlparse` if the more recent URL
162 syntax allowing parameters to be applied to each segment of the *path* portion
163 of the URL (see :rfc:`2396`) is wanted. A separate function is needed to
164 separate the path segments and parameters. This function returns a 5-tuple:
165 (addressing scheme, network location, path, query, fragment identifier).
166
167 The return value is actually an instance of a subclass of :class:`tuple`. This
168 class has the following additional read-only convenience attributes:
169
170 +------------------+-------+-------------------------+----------------------+
171 | Attribute | Index | Value | Value if not present |
172 +==================+=======+=========================+======================+
173 | :attr:`scheme` | 0 | URL scheme specifier | empty string |
174 +------------------+-------+-------------------------+----------------------+
175 | :attr:`netloc` | 1 | Network location part | empty string |
176 +------------------+-------+-------------------------+----------------------+
177 | :attr:`path` | 2 | Hierarchical path | empty string |
178 +------------------+-------+-------------------------+----------------------+
179 | :attr:`query` | 3 | Query component | empty string |
180 +------------------+-------+-------------------------+----------------------+
181 | :attr:`fragment` | 4 | Fragment identifier | empty string |
182 +------------------+-------+-------------------------+----------------------+
183 | :attr:`username` | | User name | :const:`None` |
184 +------------------+-------+-------------------------+----------------------+
185 | :attr:`password` | | Password | :const:`None` |
186 +------------------+-------+-------------------------+----------------------+
187 | :attr:`hostname` | | Host name (lower case) | :const:`None` |
188 +------------------+-------+-------------------------+----------------------+
189 | :attr:`port` | | Port number as integer, | :const:`None` |
190 | | | if present | |
191 +------------------+-------+-------------------------+----------------------+
192
193 See section :ref:`urlparse-result-object` for more information on the result
194 object.
195
Georg Brandl116aa622007-08-15 14:28:22 +0000196
197.. function:: urlunsplit(parts)
198
Georg Brandl0f7ede42008-06-23 11:23:31 +0000199 Combine the elements of a tuple as returned by :func:`urlsplit` into a
200 complete URL as a string. The *parts* argument can be any five-item
201 iterable. This may result in a slightly different, but equivalent URL, if the
202 URL that was parsed originally had unnecessary delimiters (for example, a ?
203 with an empty query; the RFC states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000204
Georg Brandl116aa622007-08-15 14:28:22 +0000205
Georg Brandlb044b2a2009-09-16 16:05:59 +0000206.. function:: urljoin(base, url, allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000207
208 Construct a full ("absolute") URL by combining a "base URL" (*base*) with
209 another URL (*url*). Informally, this uses components of the base URL, in
Georg Brandl0f7ede42008-06-23 11:23:31 +0000210 particular the addressing scheme, the network location and (part of) the
211 path, to provide missing components in the relative URL. For example:
Georg Brandl116aa622007-08-15 14:28:22 +0000212
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000213 >>> from urllib.parse import urljoin
Georg Brandl116aa622007-08-15 14:28:22 +0000214 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
215 'http://www.cwi.nl/%7Eguido/FAQ.html'
216
217 The *allow_fragments* argument has the same meaning and default as for
218 :func:`urlparse`.
219
220 .. note::
221
222 If *url* is an absolute URL (that is, starting with ``//`` or ``scheme://``),
223 the *url*'s host name and/or scheme will be present in the result. For example:
224
Christian Heimesfe337bf2008-03-23 21:54:12 +0000225 .. doctest::
Georg Brandl116aa622007-08-15 14:28:22 +0000226
227 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',
228 ... '//www.python.org/%7Eguido')
229 'http://www.python.org/%7Eguido'
230
231 If you do not want that behavior, preprocess the *url* with :func:`urlsplit` and
232 :func:`urlunsplit`, removing possible *scheme* and *netloc* parts.
233
234
235.. function:: urldefrag(url)
236
Georg Brandl0f7ede42008-06-23 11:23:31 +0000237 If *url* contains a fragment identifier, return a modified version of *url*
238 with no fragment identifier, and the fragment identifier as a separate
239 string. If there is no fragment identifier in *url*, return *url* unmodified
240 and an empty string.
Georg Brandl116aa622007-08-15 14:28:22 +0000241
Georg Brandlb044b2a2009-09-16 16:05:59 +0000242
243.. function:: quote(string, safe='/', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000244
245 Replace special characters in *string* using the ``%xx`` escape. Letters,
Georg Brandl22fff432009-10-27 20:19:02 +0000246 digits, and the characters ``'_.-'`` are never quoted. By default, this
247 function is intended for quoting the path section of URL. The optional *safe*
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000248 parameter specifies additional ASCII characters that should not be quoted
249 --- its default value is ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000250
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000251 *string* may be either a :class:`str` or a :class:`bytes`.
252
253 The optional *encoding* and *errors* parameters specify how to deal with
254 non-ASCII characters, as accepted by the :meth:`str.encode` method.
255 *encoding* defaults to ``'utf-8'``.
256 *errors* defaults to ``'strict'``, meaning unsupported characters raise a
257 :class:`UnicodeEncodeError`.
258 *encoding* and *errors* must not be supplied if *string* is a
259 :class:`bytes`, or a :class:`TypeError` is raised.
260
261 Note that ``quote(string, safe, encoding, errors)`` is equivalent to
262 ``quote_from_bytes(string.encode(encoding, errors), safe)``.
263
264 Example: ``quote('/El Niño/')`` yields ``'/El%20Ni%C3%B1o/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000265
266
Georg Brandlb044b2a2009-09-16 16:05:59 +0000267.. function:: quote_plus(string, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000268
Georg Brandl0f7ede42008-06-23 11:23:31 +0000269 Like :func:`quote`, but also replace spaces by plus signs, as required for
Georg Brandlc5605df2009-08-13 08:26:44 +0000270 quoting HTML form values when building up a query string to go into a URL.
271 Plus signs in the original string are escaped unless they are included in
272 *safe*. It also does not have *safe* default to ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000273
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000274 Example: ``quote_plus('/El Niño/')`` yields ``'%2FEl+Ni%C3%B1o%2F'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000275
Georg Brandlb044b2a2009-09-16 16:05:59 +0000276
277.. function:: quote_from_bytes(bytes, safe='/')
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000278
279 Like :func:`quote`, but accepts a :class:`bytes` object rather than a
280 :class:`str`, and does not perform string-to-bytes encoding.
281
282 Example: ``quote_from_bytes(b'a&\xef')`` yields
283 ``'a%26%EF'``.
284
Georg Brandlb044b2a2009-09-16 16:05:59 +0000285
286.. function:: unquote(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000287
288 Replace ``%xx`` escapes by their single-character equivalent.
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000289 The optional *encoding* and *errors* parameters specify how to decode
290 percent-encoded sequences into Unicode characters, as accepted by the
291 :meth:`bytes.decode` method.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000292
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000293 *string* must be a :class:`str`.
294
295 *encoding* defaults to ``'utf-8'``.
296 *errors* defaults to ``'replace'``, meaning invalid sequences are replaced
297 by a placeholder character.
298
299 Example: ``unquote('/El%20Ni%C3%B1o/')`` yields ``'/El Niño/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000300
301
Georg Brandlb044b2a2009-09-16 16:05:59 +0000302.. function:: unquote_plus(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000303
Georg Brandl0f7ede42008-06-23 11:23:31 +0000304 Like :func:`unquote`, but also replace plus signs by spaces, as required for
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000305 unquoting HTML form values.
306
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000307 *string* must be a :class:`str`.
308
309 Example: ``unquote_plus('/El+Ni%C3%B1o/')`` yields ``'/El Niño/'``.
310
Georg Brandlb044b2a2009-09-16 16:05:59 +0000311
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000312.. function:: unquote_to_bytes(string)
313
314 Replace ``%xx`` escapes by their single-octet equivalent, and return a
315 :class:`bytes` object.
316
317 *string* may be either a :class:`str` or a :class:`bytes`.
318
319 If it is a :class:`str`, unescaped non-ASCII characters in *string*
320 are encoded into UTF-8 bytes.
321
322 Example: ``unquote_to_bytes('a%26%EF')`` yields
323 ``b'a&\xef'``.
324
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000325
Senthil Kumaranfe1ad152010-07-03 17:55:41 +0000326.. function:: urlencode(query, doseq=False, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000327
Senthil Kumaran8d386872010-07-03 18:04:31 +0000328 Convert a mapping object or a sequence of two-element tuples, which may
Senthil Kumaranea54b032010-08-09 20:05:35 +0000329 either be a :class:`str` or a :class:`bytes`, to a "percent-encoded" string,
Senthil Kumaranfe1ad152010-07-03 17:55:41 +0000330 suitable to pass to :func:`urlopen` above as the optional *data* argument.
331 This is useful to pass a dictionary of form fields to a ``POST`` request.
332 The resulting string is a series of ``key=value`` pairs separated by ``'&'``
333 characters, where both *key* and *value* are quoted using :func:`quote_plus`
334 above. When a sequence of two-element tuples is used as the *query*
335 argument, the first element of each tuple is a key and the second is a
336 value. The value element in itself can be a sequence and in that case, if
337 the optional parameter *doseq* is evaluates to *True*, individual
338 ``key=value`` pairs separated by ``'&'`` are generated for each element of
339 the value sequence for the key. The order of parameters in the encoded
340 string will match the order of parameter tuples in the sequence. This module
341 provides the functions :func:`parse_qs` and :func:`parse_qsl` which are used
342 to parse query strings into Python data structures.
343
344 When *query* parameter is a :class:`str`, the *safe*, *encoding* and *error*
345 parameters are sent the :func:`quote_plus` for encoding.
346
347 .. versionchanged:: 3.2
Georg Brandl23b4f922010-10-06 08:43:56 +0000348 Query parameter supports bytes and string objects.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000349
Georg Brandl116aa622007-08-15 14:28:22 +0000350
351.. seealso::
352
Senthil Kumaran679b7b82010-04-22 05:59:54 +0000353 :rfc:`3986` - Uniform Resource Identifiers
Senthil Kumaranfe9230a2011-06-19 13:52:49 -0700354 This is the current standard (STD66). Any changes to urllib.parse module
Senthil Kumaran679b7b82010-04-22 05:59:54 +0000355 should conform to this. Certain deviations could be observed, which are
Georg Brandl4b054662010-10-06 08:56:53 +0000356 mostly for backward compatibility purposes and for certain de-facto
Senthil Kumaran679b7b82010-04-22 05:59:54 +0000357 parsing requirements as commonly observed in major browsers.
358
359 :rfc:`2396` - Uniform Resource Identifiers (URI): Generic Syntax
360 Document describing the generic syntactic requirements for both Uniform Resource
361 Names (URNs) and Uniform Resource Locators (URLs).
362
363 :rfc:`2368` - The mailto URL scheme.
364 Parsing requirements for mailto url schemes.
Georg Brandl116aa622007-08-15 14:28:22 +0000365
366 :rfc:`1808` - Relative Uniform Resource Locators
367 This Request For Comments includes the rules for joining an absolute and a
368 relative URL, including a fair number of "Abnormal Examples" which govern the
369 treatment of border cases.
370
Senthil Kumaran679b7b82010-04-22 05:59:54 +0000371 :rfc:`1738` - Uniform Resource Locators (URL)
372 This specifies the formal syntax and semantics of absolute URLs.
Georg Brandl116aa622007-08-15 14:28:22 +0000373
374
375.. _urlparse-result-object:
376
377Results of :func:`urlparse` and :func:`urlsplit`
378------------------------------------------------
379
380The result objects from the :func:`urlparse` and :func:`urlsplit` functions are
381subclasses of the :class:`tuple` type. These subclasses add the attributes
382described in those functions, as well as provide an additional method:
383
Georg Brandl116aa622007-08-15 14:28:22 +0000384.. method:: ParseResult.geturl()
385
386 Return the re-combined version of the original URL as a string. This may differ
387 from the original URL in that the scheme will always be normalized to lower case
388 and empty components may be dropped. Specifically, empty parameters, queries,
389 and fragment identifiers will be removed.
390
391 The result of this method is a fixpoint if passed back through the original
Christian Heimesfe337bf2008-03-23 21:54:12 +0000392 parsing function:
Georg Brandl116aa622007-08-15 14:28:22 +0000393
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000394 >>> import urllib.parse
Georg Brandl116aa622007-08-15 14:28:22 +0000395 >>> url = 'HTTP://www.Python.org/doc/#'
396
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000397 >>> r1 = urllib.parse.urlsplit(url)
Georg Brandl116aa622007-08-15 14:28:22 +0000398 >>> r1.geturl()
399 'http://www.Python.org/doc/'
400
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000401 >>> r2 = urllib.parse.urlsplit(r1.geturl())
Georg Brandl116aa622007-08-15 14:28:22 +0000402 >>> r2.geturl()
403 'http://www.Python.org/doc/'
404
Georg Brandl116aa622007-08-15 14:28:22 +0000405
Georg Brandl1f01deb2009-01-03 22:47:39 +0000406The following classes provide the implementations of the parse results:
Georg Brandl116aa622007-08-15 14:28:22 +0000407
Georg Brandl116aa622007-08-15 14:28:22 +0000408.. class:: BaseResult
409
Georg Brandl0f7ede42008-06-23 11:23:31 +0000410 Base class for the concrete result classes. This provides most of the
411 attribute definitions. It does not provide a :meth:`geturl` method. It is
412 derived from :class:`tuple`, but does not override the :meth:`__init__` or
413 :meth:`__new__` methods.
Georg Brandl116aa622007-08-15 14:28:22 +0000414
415
416.. class:: ParseResult(scheme, netloc, path, params, query, fragment)
417
418 Concrete class for :func:`urlparse` results. The :meth:`__new__` method is
419 overridden to support checking that the right number of arguments are passed.
420
421
422.. class:: SplitResult(scheme, netloc, path, query, fragment)
423
424 Concrete class for :func:`urlsplit` results. The :meth:`__new__` method is
425 overridden to support checking that the right number of arguments are passed.
426