blob: 7c6eaa634e91ee83ca4190aaba47ae350b40762f [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
Georg Brandl8e27fce2010-08-14 15:46:15 +000051 If the scheme value is not specified, urlparse expects the netloc value to
52 start with '//', following the syntax specifications from :rfc:`1808`.
53 Otherwise, it is not possible to distinguish between netloc and path
54 components, and would the indistinguishable component would be classified
55 as the path as in a relative URL.
Senthil Kumaran84c7d9f2010-08-04 04:50:44 +000056
57 >>> from urlparse import urlparse
58 >>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
59 ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
60 params='', query='', fragment='')
61 >>> urlparse('www.cwi.nl:80/%7Eguido/Python.html')
62 ParseResult(scheme='', netloc='', path='www.cwi.nl:80/%7Eguido/Python.html',
63 params='', query='', fragment='')
64 >>> urlparse('help/Python.html')
65 ParseResult(scheme='', netloc='', path='help/Python.html', params='',
66 query='', fragment='')
67
R. David Murrayf5077aa2010-05-25 15:36:46 +000068 If the *scheme* argument is specified, it gives the default addressing
Georg Brandl116aa622007-08-15 14:28:22 +000069 scheme, to be used only if the URL does not specify one. The default value for
70 this argument is the empty string.
71
72 If the *allow_fragments* argument is false, fragment identifiers are not
73 allowed, even if the URL's addressing scheme normally does support them. The
74 default value for this argument is :const:`True`.
75
76 The return value is actually an instance of a subclass of :class:`tuple`. This
77 class has the following additional read-only convenience attributes:
78
79 +------------------+-------+--------------------------+----------------------+
80 | Attribute | Index | Value | Value if not present |
81 +==================+=======+==========================+======================+
82 | :attr:`scheme` | 0 | URL scheme specifier | empty string |
83 +------------------+-------+--------------------------+----------------------+
84 | :attr:`netloc` | 1 | Network location part | empty string |
85 +------------------+-------+--------------------------+----------------------+
86 | :attr:`path` | 2 | Hierarchical path | empty string |
87 +------------------+-------+--------------------------+----------------------+
88 | :attr:`params` | 3 | Parameters for last path | empty string |
89 | | | element | |
90 +------------------+-------+--------------------------+----------------------+
91 | :attr:`query` | 4 | Query component | empty string |
92 +------------------+-------+--------------------------+----------------------+
93 | :attr:`fragment` | 5 | Fragment identifier | empty string |
94 +------------------+-------+--------------------------+----------------------+
95 | :attr:`username` | | User name | :const:`None` |
96 +------------------+-------+--------------------------+----------------------+
97 | :attr:`password` | | Password | :const:`None` |
98 +------------------+-------+--------------------------+----------------------+
99 | :attr:`hostname` | | Host name (lower case) | :const:`None` |
100 +------------------+-------+--------------------------+----------------------+
101 | :attr:`port` | | Port number as integer, | :const:`None` |
102 | | | if present | |
103 +------------------+-------+--------------------------+----------------------+
104
105 See section :ref:`urlparse-result-object` for more information on the result
106 object.
107
Senthil Kumaran7a1e09f2010-04-22 12:19:46 +0000108 .. versionchanged:: 3.2
109 Added IPv6 URL parsing capabilities.
110
Georg Brandl116aa622007-08-15 14:28:22 +0000111
Georg Brandl7f01a132009-09-16 15:58:14 +0000112.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000113
114 Parse a query string given as a string argument (data of type
115 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a
116 dictionary. The dictionary keys are the unique query variable names and the
117 values are lists of values for each name.
118
119 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000120 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000121 indicates that blanks should be retained as blank strings. The default false
122 value indicates that blank values are to be ignored and treated as if they were
123 not included.
124
125 The optional argument *strict_parsing* is a flag indicating what to do with
126 parsing errors. If false (the default), errors are silently ignored. If true,
127 errors raise a :exc:`ValueError` exception.
128
Georg Brandl7fe2c4a2008-12-05 07:32:56 +0000129 Use the :func:`urllib.parse.urlencode` function to convert such
130 dictionaries into query strings.
Facundo Batistac469d4c2008-09-03 22:49:01 +0000131
132
Georg Brandl7f01a132009-09-16 15:58:14 +0000133.. function:: parse_qsl(qs, keep_blank_values=False, strict_parsing=False)
Facundo Batistac469d4c2008-09-03 22:49:01 +0000134
135 Parse a query string given as a string argument (data of type
136 :mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of
137 name, value pairs.
138
139 The optional argument *keep_blank_values* is a flag indicating whether blank
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000140 values in percent-encoded queries should be treated as blank strings. A true value
Facundo Batistac469d4c2008-09-03 22:49:01 +0000141 indicates that blanks should be retained as blank strings. The default false
142 value indicates that blank values are to be ignored and treated as if they were
143 not included.
144
145 The optional argument *strict_parsing* is a flag indicating what to do with
146 parsing errors. If false (the default), errors are silently ignored. If true,
147 errors raise a :exc:`ValueError` exception.
148
149 Use the :func:`urllib.parse.urlencode` function to convert such lists of pairs into
150 query strings.
151
152
Georg Brandl116aa622007-08-15 14:28:22 +0000153.. function:: urlunparse(parts)
154
Georg Brandl0f7ede42008-06-23 11:23:31 +0000155 Construct a URL from a tuple as returned by ``urlparse()``. The *parts*
156 argument can be any six-item iterable. This may result in a slightly
157 different, but equivalent URL, if the URL that was parsed originally had
158 unnecessary delimiters (for example, a ``?`` with an empty query; the RFC
159 states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000160
161
R. David Murrayf5077aa2010-05-25 15:36:46 +0000162.. function:: urlsplit(urlstring, scheme='', allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000163
164 This is similar to :func:`urlparse`, but does not split the params from the URL.
165 This should generally be used instead of :func:`urlparse` if the more recent URL
166 syntax allowing parameters to be applied to each segment of the *path* portion
167 of the URL (see :rfc:`2396`) is wanted. A separate function is needed to
168 separate the path segments and parameters. This function returns a 5-tuple:
169 (addressing scheme, network location, path, query, fragment identifier).
170
171 The return value is actually an instance of a subclass of :class:`tuple`. This
172 class has the following additional read-only convenience attributes:
173
174 +------------------+-------+-------------------------+----------------------+
175 | Attribute | Index | Value | Value if not present |
176 +==================+=======+=========================+======================+
177 | :attr:`scheme` | 0 | URL scheme specifier | empty string |
178 +------------------+-------+-------------------------+----------------------+
179 | :attr:`netloc` | 1 | Network location part | empty string |
180 +------------------+-------+-------------------------+----------------------+
181 | :attr:`path` | 2 | Hierarchical path | empty string |
182 +------------------+-------+-------------------------+----------------------+
183 | :attr:`query` | 3 | Query component | empty string |
184 +------------------+-------+-------------------------+----------------------+
185 | :attr:`fragment` | 4 | Fragment identifier | empty string |
186 +------------------+-------+-------------------------+----------------------+
187 | :attr:`username` | | User name | :const:`None` |
188 +------------------+-------+-------------------------+----------------------+
189 | :attr:`password` | | Password | :const:`None` |
190 +------------------+-------+-------------------------+----------------------+
191 | :attr:`hostname` | | Host name (lower case) | :const:`None` |
192 +------------------+-------+-------------------------+----------------------+
193 | :attr:`port` | | Port number as integer, | :const:`None` |
194 | | | if present | |
195 +------------------+-------+-------------------------+----------------------+
196
197 See section :ref:`urlparse-result-object` for more information on the result
198 object.
199
Georg Brandl116aa622007-08-15 14:28:22 +0000200
201.. function:: urlunsplit(parts)
202
Georg Brandl0f7ede42008-06-23 11:23:31 +0000203 Combine the elements of a tuple as returned by :func:`urlsplit` into a
204 complete URL as a string. The *parts* argument can be any five-item
205 iterable. This may result in a slightly different, but equivalent URL, if the
206 URL that was parsed originally had unnecessary delimiters (for example, a ?
207 with an empty query; the RFC states that these are equivalent).
Georg Brandl116aa622007-08-15 14:28:22 +0000208
Georg Brandl116aa622007-08-15 14:28:22 +0000209
Georg Brandl7f01a132009-09-16 15:58:14 +0000210.. function:: urljoin(base, url, allow_fragments=True)
Georg Brandl116aa622007-08-15 14:28:22 +0000211
212 Construct a full ("absolute") URL by combining a "base URL" (*base*) with
213 another URL (*url*). Informally, this uses components of the base URL, in
Georg Brandl0f7ede42008-06-23 11:23:31 +0000214 particular the addressing scheme, the network location and (part of) the
215 path, to provide missing components in the relative URL. For example:
Georg Brandl116aa622007-08-15 14:28:22 +0000216
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000217 >>> from urllib.parse import urljoin
Georg Brandl116aa622007-08-15 14:28:22 +0000218 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
219 'http://www.cwi.nl/%7Eguido/FAQ.html'
220
221 The *allow_fragments* argument has the same meaning and default as for
222 :func:`urlparse`.
223
224 .. note::
225
226 If *url* is an absolute URL (that is, starting with ``//`` or ``scheme://``),
227 the *url*'s host name and/or scheme will be present in the result. For example:
228
Christian Heimesfe337bf2008-03-23 21:54:12 +0000229 .. doctest::
Georg Brandl116aa622007-08-15 14:28:22 +0000230
231 >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',
232 ... '//www.python.org/%7Eguido')
233 'http://www.python.org/%7Eguido'
234
235 If you do not want that behavior, preprocess the *url* with :func:`urlsplit` and
236 :func:`urlunsplit`, removing possible *scheme* and *netloc* parts.
237
238
239.. function:: urldefrag(url)
240
Georg Brandl0f7ede42008-06-23 11:23:31 +0000241 If *url* contains a fragment identifier, return a modified version of *url*
242 with no fragment identifier, and the fragment identifier as a separate
243 string. If there is no fragment identifier in *url*, return *url* unmodified
244 and an empty string.
Georg Brandl116aa622007-08-15 14:28:22 +0000245
Georg Brandl7f01a132009-09-16 15:58:14 +0000246
247.. function:: quote(string, safe='/', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000248
249 Replace special characters in *string* using the ``%xx`` escape. Letters,
Senthil Kumaran8aa8bbe2009-08-31 16:43:45 +0000250 digits, and the characters ``'_.-'`` are never quoted. By default, this
251 function is intended for quoting the path section of URL. The optional *safe*
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000252 parameter specifies additional ASCII characters that should not be quoted
253 --- its default value is ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000254
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000255 *string* may be either a :class:`str` or a :class:`bytes`.
256
257 The optional *encoding* and *errors* parameters specify how to deal with
258 non-ASCII characters, as accepted by the :meth:`str.encode` method.
259 *encoding* defaults to ``'utf-8'``.
260 *errors* defaults to ``'strict'``, meaning unsupported characters raise a
261 :class:`UnicodeEncodeError`.
262 *encoding* and *errors* must not be supplied if *string* is a
263 :class:`bytes`, or a :class:`TypeError` is raised.
264
265 Note that ``quote(string, safe, encoding, errors)`` is equivalent to
266 ``quote_from_bytes(string.encode(encoding, errors), safe)``.
267
268 Example: ``quote('/El Niño/')`` yields ``'/El%20Ni%C3%B1o/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000269
270
Georg Brandl7f01a132009-09-16 15:58:14 +0000271.. function:: quote_plus(string, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000272
Georg Brandl0f7ede42008-06-23 11:23:31 +0000273 Like :func:`quote`, but also replace spaces by plus signs, as required for
Georg Brandl81c09db2009-07-29 07:27:08 +0000274 quoting HTML form values when building up a query string to go into a URL.
275 Plus signs in the original string are escaped unless they are included in
276 *safe*. It also does not have *safe* default to ``'/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000277
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000278 Example: ``quote_plus('/El Niño/')`` yields ``'%2FEl+Ni%C3%B1o%2F'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000279
Georg Brandl7f01a132009-09-16 15:58:14 +0000280
281.. function:: quote_from_bytes(bytes, safe='/')
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000282
283 Like :func:`quote`, but accepts a :class:`bytes` object rather than a
284 :class:`str`, and does not perform string-to-bytes encoding.
285
286 Example: ``quote_from_bytes(b'a&\xef')`` yields
287 ``'a%26%EF'``.
288
Georg Brandl7f01a132009-09-16 15:58:14 +0000289
290.. function:: unquote(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000291
292 Replace ``%xx`` escapes by their single-character equivalent.
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000293 The optional *encoding* and *errors* parameters specify how to decode
294 percent-encoded sequences into Unicode characters, as accepted by the
295 :meth:`bytes.decode` method.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000296
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000297 *string* must be a :class:`str`.
298
299 *encoding* defaults to ``'utf-8'``.
300 *errors* defaults to ``'replace'``, meaning invalid sequences are replaced
301 by a placeholder character.
302
303 Example: ``unquote('/El%20Ni%C3%B1o/')`` yields ``'/El Niño/'``.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000304
305
Georg Brandl7f01a132009-09-16 15:58:14 +0000306.. function:: unquote_plus(string, encoding='utf-8', errors='replace')
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000307
Georg Brandl0f7ede42008-06-23 11:23:31 +0000308 Like :func:`unquote`, but also replace plus signs by spaces, as required for
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000309 unquoting HTML form values.
310
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000311 *string* must be a :class:`str`.
312
313 Example: ``unquote_plus('/El+Ni%C3%B1o/')`` yields ``'/El Niño/'``.
314
Georg Brandl7f01a132009-09-16 15:58:14 +0000315
Guido van Rossum52dbbb92008-08-18 21:44:30 +0000316.. function:: unquote_to_bytes(string)
317
318 Replace ``%xx`` escapes by their single-octet equivalent, and return a
319 :class:`bytes` object.
320
321 *string* may be either a :class:`str` or a :class:`bytes`.
322
323 If it is a :class:`str`, unescaped non-ASCII characters in *string*
324 are encoded into UTF-8 bytes.
325
326 Example: ``unquote_to_bytes('a%26%EF')`` yields
327 ``b'a&\xef'``.
328
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000329
Senthil Kumarandf022da2010-07-03 17:48:22 +0000330.. function:: urlencode(query, doseq=False, safe='', encoding=None, errors=None)
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000331
Senthil Kumarandf022da2010-07-03 17:48:22 +0000332 Convert a mapping object or a sequence of two-element tuples, which may
Senthil Kumaranf0769e82010-08-09 19:53:52 +0000333 either be a :class:`str` or a :class:`bytes`, to a "percent-encoded" string,
Senthil Kumarandf022da2010-07-03 17:48:22 +0000334 suitable to pass to :func:`urlopen` above as the optional *data* argument.
335 This is useful to pass a dictionary of form fields to a ``POST`` request.
336 The resulting string is a series of ``key=value`` pairs separated by ``'&'``
337 characters, where both *key* and *value* are quoted using :func:`quote_plus`
338 above. When a sequence of two-element tuples is used as the *query*
339 argument, the first element of each tuple is a key and the second is a
340 value. The value element in itself can be a sequence and in that case, if
341 the optional parameter *doseq* is evaluates to *True*, individual
342 ``key=value`` pairs separated by ``'&'`` are generated for each element of
343 the value sequence for the key. The order of parameters in the encoded
344 string will match the order of parameter tuples in the sequence. This module
345 provides the functions :func:`parse_qs` and :func:`parse_qsl` which are used
346 to parse query strings into Python data structures.
347
348 When *query* parameter is a :class:`str`, the *safe*, *encoding* and *error*
349 parameters are sent the :func:`quote_plus` for encoding.
350
351 .. versionchanged:: 3.2
Georg Brandl67b21b72010-08-17 15:07:14 +0000352 Query parameter supports bytes and string objects.
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000353
Georg Brandl116aa622007-08-15 14:28:22 +0000354
355.. seealso::
356
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000357 :rfc:`3986` - Uniform Resource Identifiers
358 This is the current standard (STD66). Any changes to urlparse module
359 should conform to this. Certain deviations could be observed, which are
Georg Brandl6faee4e2010-09-21 14:48:28 +0000360 mostly for backward compatibility purposes and for certain de-facto
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000361 parsing requirements as commonly observed in major browsers.
362
363 :rfc:`2732` - Format for Literal IPv6 Addresses in URL's.
364 This specifies the parsing requirements of IPv6 URLs.
365
366 :rfc:`2396` - Uniform Resource Identifiers (URI): Generic Syntax
367 Document describing the generic syntactic requirements for both Uniform Resource
368 Names (URNs) and Uniform Resource Locators (URLs).
369
370 :rfc:`2368` - The mailto URL scheme.
371 Parsing requirements for mailto url schemes.
Georg Brandl116aa622007-08-15 14:28:22 +0000372
373 :rfc:`1808` - Relative Uniform Resource Locators
374 This Request For Comments includes the rules for joining an absolute and a
375 relative URL, including a fair number of "Abnormal Examples" which govern the
376 treatment of border cases.
377
Senthil Kumaran6257bdd2010-04-22 05:53:18 +0000378 :rfc:`1738` - Uniform Resource Locators (URL)
379 This specifies the formal syntax and semantics of absolute URLs.
Georg Brandl116aa622007-08-15 14:28:22 +0000380
381
382.. _urlparse-result-object:
383
384Results of :func:`urlparse` and :func:`urlsplit`
385------------------------------------------------
386
387The result objects from the :func:`urlparse` and :func:`urlsplit` functions are
388subclasses of the :class:`tuple` type. These subclasses add the attributes
389described in those functions, as well as provide an additional method:
390
Georg Brandl116aa622007-08-15 14:28:22 +0000391.. method:: ParseResult.geturl()
392
393 Return the re-combined version of the original URL as a string. This may differ
394 from the original URL in that the scheme will always be normalized to lower case
395 and empty components may be dropped. Specifically, empty parameters, queries,
396 and fragment identifiers will be removed.
397
398 The result of this method is a fixpoint if passed back through the original
Christian Heimesfe337bf2008-03-23 21:54:12 +0000399 parsing function:
Georg Brandl116aa622007-08-15 14:28:22 +0000400
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000401 >>> import urllib.parse
Georg Brandl116aa622007-08-15 14:28:22 +0000402 >>> url = 'HTTP://www.Python.org/doc/#'
403
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000404 >>> r1 = urllib.parse.urlsplit(url)
Georg Brandl116aa622007-08-15 14:28:22 +0000405 >>> r1.geturl()
406 'http://www.Python.org/doc/'
407
Senthil Kumaranaca8fd72008-06-23 04:41:59 +0000408 >>> r2 = urllib.parse.urlsplit(r1.geturl())
Georg Brandl116aa622007-08-15 14:28:22 +0000409 >>> r2.geturl()
410 'http://www.Python.org/doc/'
411
Georg Brandl116aa622007-08-15 14:28:22 +0000412
Georg Brandl1f01deb2009-01-03 22:47:39 +0000413The following classes provide the implementations of the parse results:
Georg Brandl116aa622007-08-15 14:28:22 +0000414
Georg Brandl116aa622007-08-15 14:28:22 +0000415.. class:: BaseResult
416
Georg Brandl0f7ede42008-06-23 11:23:31 +0000417 Base class for the concrete result classes. This provides most of the
418 attribute definitions. It does not provide a :meth:`geturl` method. It is
419 derived from :class:`tuple`, but does not override the :meth:`__init__` or
420 :meth:`__new__` methods.
Georg Brandl116aa622007-08-15 14:28:22 +0000421
422
423.. class:: ParseResult(scheme, netloc, path, params, query, fragment)
424
425 Concrete class for :func:`urlparse` results. The :meth:`__new__` method is
426 overridden to support checking that the right number of arguments are passed.
427
428
429.. class:: SplitResult(scheme, netloc, path, query, fragment)
430
431 Concrete class for :func:`urlsplit` results. The :meth:`__new__` method is
432 overridden to support checking that the right number of arguments are passed.
433