blob: a15ff4770a010b59ee19fc09ebc29a1a1a777785 [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 Murrayf5077aa2010-05-25 15:36:46 +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 Kumaran7089a4e2010-11-07 12:57:04 +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 Kumaran84c7d9f2010-08-04 04:50:44 +000055
56 >>> from urlparse import urlparse
57 >>> 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 Murrayf5077aa2010-05-25 15:36:46 +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
Senthil Kumaran7a1e09f2010-04-22 12:19:46 +0000107 .. versionchanged:: 3.2
108 Added IPv6 URL parsing capabilities.
109
Georg Brandl116aa622007-08-15 14:28:22 +0000110
Georg Brandl7f01a132009-09-16 15:58:14 +0000111.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000112
113 Parse a query string given as a string argument (data of type
114 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a
115 dictionary. The dictionary keys are the unique query variable names and the
116 values are lists of values for each name.
117
118 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000119 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000120 indicates that blanks should be retained as blank strings. The default false
121 value indicates that blank values are to be ignored and treated as if they were
122 not included.
123
124 The optional argument *strict_parsing* is a flag indicating what to do with
125 parsing errors. If false (the default), errors are silently ignored. If true,
126 errors raise a :exc:`ValueError` exception.
127
Georg Brandl7fe2c4a2008-12-05 07:32:56 +0000128 Use the :func:`urllib.parse.urlencode` function to convert such
129 dictionaries into query strings.
Facundo Batistac469d4c2008-09-03 22:49:01 +0000130
131
Georg Brandl7f01a132009-09-16 15:58:14 +0000132.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000133
134 Parse a query string given as a string argument (data of type
135 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of
136 name, value pairs.
137
138 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000139 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000140 indicates that blanks should be retained as blank strings. The default false
141 value indicates that blank values are to be ignored and treated as if they were
142 not included.
143
144 The optional argument *strict_parsing* is a flag indicating what to do with
145 parsing errors. If false (the default), errors are silently ignored. If true,
146 errors raise a :exc:`ValueError` exception.
147
148 Use the :func:`urllib.parse.urlencode` function to convert such lists of pairs into
149 query strings.
150
151
Georg Brandl116aa622007-08-15 14:28:22 +0000152.. function:: urlunparse(parts)
153
Georg Brandl0f7ede42008-06-23 11:23:31 +0000154 Construct a URL from a tuple as returned by ``urlparse()``. The *parts*
155 argument can be any six-item iterable. This may result in a slightly
156 different, but equivalent URL, if the URL that was parsed originally had
157 unnecessary delimiters (for example, a ``?`` with an empty query; the RFC
158 states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000159
160
R. David Murrayf5077aa2010-05-25 15:36:46 +0000161.. function:: urlsplit(urlstring, scheme='', allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000162
163 This is similar to :func:`urlparse`, but does not split the params from the URL.
164 This should generally be used instead of :func:`urlparse` if the more recent URL
165 syntax allowing parameters to be applied to each segment of the *path* portion
166 of the URL (see :rfc:`2396`) is wanted. A separate function is needed to
167 separate the path segments and parameters. This function returns a 5-tuple:
168 (addressing scheme, network location, path, query, fragment identifier).
169
170 The return value is actually an instance of a subclass of :class:`tuple`. This
171 class has the following additional read-only convenience attributes:
172
173 +------------------+-------+-------------------------+----------------------+
174 | Attribute | Index | Value | Value if not present |
175 +==================+=======+=========================+======================+
176 | :attr:`scheme` | 0 | URL scheme specifier | empty string |
177 +------------------+-------+-------------------------+----------------------+
178 | :attr:`netloc` | 1 | Network location part | empty string |
179 +------------------+-------+-------------------------+----------------------+
180 | :attr:`path` | 2 | Hierarchical path | empty string |
181 +------------------+-------+-------------------------+----------------------+
182 | :attr:`query` | 3 | Query component | empty string |
183 +------------------+-------+-------------------------+----------------------+
184 | :attr:`fragment` | 4 | Fragment identifier | empty string |
185 +------------------+-------+-------------------------+----------------------+
186 | :attr:`username` | | User name | :const:`None` |
187 +------------------+-------+-------------------------+----------------------+
188 | :attr:`password` | | Password | :const:`None` |
189 +------------------+-------+-------------------------+----------------------+
190 | :attr:`hostname` | | Host name (lower case) | :const:`None` |
191 +------------------+-------+-------------------------+----------------------+
192 | :attr:`port` | | Port number as integer, | :const:`None` |
193 | | | if present | |
194 +------------------+-------+-------------------------+----------------------+
195
196 See section :ref:`urlparse-result-object` for more information on the result
197 object.
198
Georg Brandl116aa622007-08-15 14:28:22 +0000199
200.. function:: urlunsplit(parts)
201
Georg Brandl0f7ede42008-06-23 11:23:31 +0000202 Combine the elements of a tuple as returned by :func:`urlsplit` into a
203 complete URL as a string. The *parts* argument can be any five-item
204 iterable. This may result in a slightly different, but equivalent URL, if the
205 URL that was parsed originally had unnecessary delimiters (for example, a ?
206 with an empty query; the RFC states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000207
Georg Brandl116aa622007-08-15 14:28:22 +0000208
Georg Brandl7f01a132009-09-16 15:58:14 +0000209.. function:: urljoin(base, url, allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000210
211 Construct a full ("absolute") URL by combining a "base URL" (*base*) with
212 another URL (*url*). Informally, this uses components of the base URL, in
Georg Brandl0f7ede42008-06-23 11:23:31 +0000213 particular the addressing scheme, the network location and (part of) the
214 path, to provide missing components in the relative URL. For example:
Georg Brandl116aa622007-08-15 14:28:22 +0000215
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000216 >>> from urllib.parse import urljoin
Georg Brandl116aa622007-08-15 14:28:22 +0000217 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
218 'http://www.cwi.nl/%7Eguido/FAQ.html'
219
220 The *allow_fragments* argument has the same meaning and default as for
221 :func:`urlparse`.
222
223 .. note::
224
225 If *url* is an absolute URL (that is, starting with ``//`` or ``scheme://``),
226 the *url*'s host name and/or scheme will be present in the result. For example:
227
Christian Heimesfe337bf2008-03-23 21:54:12 +0000228 .. doctest::
Georg Brandl116aa622007-08-15 14:28:22 +0000229
230 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',
231 ... '//www.python.org/%7Eguido')
232 'http://www.python.org/%7Eguido'
233
234 If you do not want that behavior, preprocess the *url* with :func:`urlsplit` and
235 :func:`urlunsplit`, removing possible *scheme* and *netloc* parts.
236
237
238.. function:: urldefrag(url)
239
Georg Brandl0f7ede42008-06-23 11:23:31 +0000240 If *url* contains a fragment identifier, return a modified version of *url*
241 with no fragment identifier, and the fragment identifier as a separate
242 string. If there is no fragment identifier in *url*, return *url* unmodified
243 and an empty string.
Georg Brandl116aa622007-08-15 14:28:22 +0000244
Georg Brandl7f01a132009-09-16 15:58:14 +0000245
246.. function:: quote(string, safe='/', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000247
248 Replace special characters in *string* using the ``%xx`` escape. Letters,
Senthil Kumaran8aa8bbe2009-08-31 16:43:45 +0000249 digits, and the characters ``'_.-'`` are never quoted. By default, this
250 function is intended for quoting the path section of URL. The optional *safe*
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000251 parameter specifies additional ASCII characters that should not be quoted
252 --- its default value is ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000253
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000254 *string* may be either a :class:`str` or a :class:`bytes`.
255
256 The optional *encoding* and *errors* parameters specify how to deal with
257 non-ASCII characters, as accepted by the :meth:`str.encode` method.
258 *encoding* defaults to ``'utf-8'``.
259 *errors* defaults to ``'strict'``, meaning unsupported characters raise a
260 :class:`UnicodeEncodeError`.
261 *encoding* and *errors* must not be supplied if *string* is a
262 :class:`bytes`, or a :class:`TypeError` is raised.
263
264 Note that ``quote(string, safe, encoding, errors)`` is equivalent to
265 ``quote_from_bytes(string.encode(encoding, errors), safe)``.
266
267 Example: ``quote('/El Niño/')`` yields ``'/El%20Ni%C3%B1o/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000268
269
Georg Brandl7f01a132009-09-16 15:58:14 +0000270.. function:: quote_plus(string, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000271
Georg Brandl0f7ede42008-06-23 11:23:31 +0000272 Like :func:`quote`, but also replace spaces by plus signs, as required for
Georg Brandl81c09db2009-07-29 07:27:08 +0000273 quoting HTML form values when building up a query string to go into a URL.
274 Plus signs in the original string are escaped unless they are included in
275 *safe*. It also does not have *safe* default to ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000276
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000277 Example: ``quote_plus('/El Niño/')`` yields ``'%2FEl+Ni%C3%B1o%2F'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000278
Georg Brandl7f01a132009-09-16 15:58:14 +0000279
280.. function:: quote_from_bytes(bytes, safe='/')
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000281
282 Like :func:`quote`, but accepts a :class:`bytes` object rather than a
283 :class:`str`, and does not perform string-to-bytes encoding.
284
285 Example: ``quote_from_bytes(b'a&\xef')`` yields
286 ``'a%26%EF'``.
287
Georg Brandl7f01a132009-09-16 15:58:14 +0000288
289.. function:: unquote(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000290
291 Replace ``%xx`` escapes by their single-character equivalent.
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000292 The optional *encoding* and *errors* parameters specify how to decode
293 percent-encoded sequences into Unicode characters, as accepted by the
294 :meth:`bytes.decode` method.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000295
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000296 *string* must be a :class:`str`.
297
298 *encoding* defaults to ``'utf-8'``.
299 *errors* defaults to ``'replace'``, meaning invalid sequences are replaced
300 by a placeholder character.
301
302 Example: ``unquote('/El%20Ni%C3%B1o/')`` yields ``'/El Niño/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000303
304
Georg Brandl7f01a132009-09-16 15:58:14 +0000305.. function:: unquote_plus(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000306
Georg Brandl0f7ede42008-06-23 11:23:31 +0000307 Like :func:`unquote`, but also replace plus signs by spaces, as required for
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000308 unquoting HTML form values.
309
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000310 *string* must be a :class:`str`.
311
312 Example: ``unquote_plus('/El+Ni%C3%B1o/')`` yields ``'/El Niño/'``.
313
Georg Brandl7f01a132009-09-16 15:58:14 +0000314
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000315.. function:: unquote_to_bytes(string)
316
317 Replace ``%xx`` escapes by their single-octet equivalent, and return a
318 :class:`bytes` object.
319
320 *string* may be either a :class:`str` or a :class:`bytes`.
321
322 If it is a :class:`str`, unescaped non-ASCII characters in *string*
323 are encoded into UTF-8 bytes.
324
325 Example: ``unquote_to_bytes('a%26%EF')`` yields
326 ``b'a&\xef'``.
327
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000328
Senthil Kumarandf022da2010-07-03 17:48:22 +0000329.. function:: urlencode(query, doseq=False, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000330
Senthil Kumarandf022da2010-07-03 17:48:22 +0000331 Convert a mapping object or a sequence of two-element tuples, which may
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000332 either be a :class:`str` or a :class:`bytes`, to a "percent-encoded" string,
Senthil Kumarandf022da2010-07-03 17:48:22 +0000333 suitable to pass to :func:`urlopen` above as the optional *data* argument.
334 This is useful to pass a dictionary of form fields to a ``POST`` request.
335 The resulting string is a series of ``key=value`` pairs separated by ``'&'``
336 characters, where both *key* and *value* are quoted using :func:`quote_plus`
337 above. When a sequence of two-element tuples is used as the *query*
338 argument, the first element of each tuple is a key and the second is a
339 value. The value element in itself can be a sequence and in that case, if
340 the optional parameter *doseq* is evaluates to *True*, individual
341 ``key=value`` pairs separated by ``'&'`` are generated for each element of
342 the value sequence for the key. The order of parameters in the encoded
343 string will match the order of parameter tuples in the sequence. This module
344 provides the functions :func:`parse_qs` and :func:`parse_qsl` which are used
345 to parse query strings into Python data structures.
346
347 When *query* parameter is a :class:`str`, the *safe*, *encoding* and *error*
348 parameters are sent the :func:`quote_plus` for encoding.
349
350 .. versionchanged:: 3.2
Georg Brandl67b21b72010-08-17 15:07:14 +0000351 Query parameter supports bytes and string objects.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000352
Georg Brandl116aa622007-08-15 14:28:22 +0000353
354.. seealso::
355
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000356 :rfc:`3986` - Uniform Resource Identifiers
357 This is the current standard (STD66). Any changes to urlparse module
358 should conform to this. Certain deviations could be observed, which are
Georg Brandl6faee4e2010-09-21 14:48:28 +0000359 mostly for backward compatibility purposes and for certain de-facto
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000360 parsing requirements as commonly observed in major browsers.
361
362 :rfc:`2732` - Format for Literal IPv6 Addresses in URL's.
363 This specifies the parsing requirements of IPv6 URLs.
364
365 :rfc:`2396` - Uniform Resource Identifiers (URI): Generic Syntax
366 Document describing the generic syntactic requirements for both Uniform Resource
367 Names (URNs) and Uniform Resource Locators (URLs).
368
369 :rfc:`2368` - The mailto URL scheme.
370 Parsing requirements for mailto url schemes.
Georg Brandl116aa622007-08-15 14:28:22 +0000371
372 :rfc:`1808` - Relative Uniform Resource Locators
373 This Request For Comments includes the rules for joining an absolute and a
374 relative URL, including a fair number of "Abnormal Examples" which govern the
375 treatment of border cases.
376
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000377 :rfc:`1738` - Uniform Resource Locators (URL)
378 This specifies the formal syntax and semantics of absolute URLs.
Georg Brandl116aa622007-08-15 14:28:22 +0000379
380
381.. _urlparse-result-object:
382
383Results of :func:`urlparse` and :func:`urlsplit`
384------------------------------------------------
385
386The result objects from the :func:`urlparse` and :func:`urlsplit` functions are
387subclasses of the :class:`tuple` type. These subclasses add the attributes
388described in those functions, as well as provide an additional method:
389
Georg Brandl116aa622007-08-15 14:28:22 +0000390.. method:: ParseResult.geturl()
391
392 Return the re-combined version of the original URL as a string. This may differ
393 from the original URL in that the scheme will always be normalized to lower case
394 and empty components may be dropped. Specifically, empty parameters, queries,
395 and fragment identifiers will be removed.
396
397 The result of this method is a fixpoint if passed back through the original
Christian Heimesfe337bf2008-03-23 21:54:12 +0000398 parsing function:
Georg Brandl116aa622007-08-15 14:28:22 +0000399
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000400 >>> import urllib.parse
Georg Brandl116aa622007-08-15 14:28:22 +0000401 >>> url = 'HTTP://www.Python.org/doc/#'
402
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000403 >>> r1 = urllib.parse.urlsplit(url)
Georg Brandl116aa622007-08-15 14:28:22 +0000404 >>> r1.geturl()
405 'http://www.Python.org/doc/'
406
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000407 >>> r2 = urllib.parse.urlsplit(r1.geturl())
Georg Brandl116aa622007-08-15 14:28:22 +0000408 >>> r2.geturl()
409 'http://www.Python.org/doc/'
410
Georg Brandl116aa622007-08-15 14:28:22 +0000411
Georg Brandl1f01deb2009-01-03 22:47:39 +0000412The following classes provide the implementations of the parse results:
Georg Brandl116aa622007-08-15 14:28:22 +0000413
Georg Brandl116aa622007-08-15 14:28:22 +0000414.. class:: BaseResult
415
Georg Brandl0f7ede42008-06-23 11:23:31 +0000416 Base class for the concrete result classes. This provides most of the
417 attribute definitions. It does not provide a :meth:`geturl` method. It is
418 derived from :class:`tuple`, but does not override the :meth:`__init__` or
419 :meth:`__new__` methods.
Georg Brandl116aa622007-08-15 14:28:22 +0000420
421
422.. class:: ParseResult(scheme, netloc, path, params, query, fragment)
423
424 Concrete class for :func:`urlparse` results. The :meth:`__new__` method is
425 overridden to support checking that the right number of arguments are passed.
426
427
428.. class:: SplitResult(scheme, netloc, path, query, fragment)
429
430 Concrete class for :func:`urlsplit` results. The :meth:`__new__` method is
431 overridden to support checking that the right number of arguments are passed.
432