Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: tools/telemetry/third_party/gsutil/third_party/six/documentation/index.rst

Issue 1258583006: Add gsutil 4.13 to telemetry/third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo all other changes so this just add gsutil to third_party Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 Six: Python 2 and 3 Compatibility Library
2 =========================================
3
4 .. module:: six
5 :synopsis: Python 2 and 3 compatibility
6
7 .. moduleauthor:: Benjamin Peterson <benjamin@python.org>
8 .. sectionauthor:: Benjamin Peterson <benjamin@python.org>
9
10
11 Six provides simple utilities for wrapping over differences between Python 2 and
12 Python 3. It is intended to support codebases that work on both Python 2 and 3
13 without modification. six consists of only one Python file, so it is painless
14 to copy into a project.
15
16 Six can be downloaded on `PyPi <http://pypi.python.org/pypi/six/>`_. Its bug
17 tracker and code hosting is on `BitBucket <http://bitbucket.org/gutworth/six>`_.
18
19 The name, "six", comes from the fact that 2*3 equals 6. Why not addition?
20 Multiplication is more powerful, and, anyway, "five" has already been snatched
21 away by the Zope Five project.
22
23
24 Indices and tables
25 ------------------
26
27 * :ref:`genindex`
28 * :ref:`search`
29
30
31 Package contents
32 ----------------
33
34 .. data:: PY2
35
36 A boolean indicating if the code is running on Python 2.
37
38 .. data:: PY3
39
40 A boolean indicating if the code is running on Python 3.
41
42
43 Constants
44 >>>>>>>>>
45
46 Six provides constants that may differ between Python versions. Ones ending
47 ``_types`` are mostly useful as the second argument to ``isinstance`` or
48 ``issubclass``.
49
50
51 .. data:: class_types
52
53 Possible class types. In Python 2, this encompasses old-style and new-style
54 classes. In Python 3, this is just new-styles.
55
56
57 .. data:: integer_types
58
59 Possible integer types. In Python 2, this is :func:`py2:long` and
60 :func:`py2:int`, and in Python 3, just :func:`py3:int`.
61
62
63 .. data:: string_types
64
65 Possible types for text data. This is :func:`py2:basestring` in Python 2 and
66 :func:`py3:str` in Python 3.
67
68
69 .. data:: text_type
70
71 Type for representing (Unicode) textual data. This is :func:`py2:unicode` in
72 Python 2 and :func:`py3:str` in Python 3.
73
74
75 .. data:: binary_type
76
77 Type for representing binary data. This is :func:`py2:str` in Python 2 and
78 :func:`py3:bytes` in Python 3.
79
80
81 .. data:: MAXSIZE
82
83 The maximum size of a container like :func:`py3:list` or :func:`py3:dict`.
84 This is equivalent to :data:`py3:sys.maxsize` in Python 2.6 and later
85 (including 3.x). Note, this is temptingly similar to, but not the same as
86 :data:`py2:sys.maxint` in Python 2. There is no direct equivalent to
87 :data:`py2:sys.maxint` in Python 3 because its integer type has no limits
88 aside from memory.
89
90
91 Here's example usage of the module::
92
93 import six
94
95 def dispatch_types(value):
96 if isinstance(value, six.integer_types):
97 handle_integer(value)
98 elif isinstance(value, six.class_types):
99 handle_class(value)
100 elif isinstance(value, six.string_types):
101 handle_string(value)
102
103
104 Object model compatibility
105 >>>>>>>>>>>>>>>>>>>>>>>>>>
106
107 Python 3 renamed the attributes of several intepreter data structures. The
108 following accessors are available. Note that the recommended way to inspect
109 functions and methods is the stdlib :mod:`py3:inspect` module.
110
111
112 .. function:: get_unbound_function(meth)
113
114 Get the function out of unbound method *meth*. In Python 3, unbound methods
115 don't exist, so this function just returns *meth* unchanged. Example
116 usage::
117
118 from six import get_unbound_function
119
120 class X(object):
121 def method(self):
122 pass
123 method_function = get_unbound_function(X.method)
124
125
126 .. function:: get_method_function(meth)
127
128 Get the function out of method object *meth*.
129
130
131 .. function:: get_method_self(meth)
132
133 Get the ``self`` of bound method *meth*.
134
135
136 .. function:: get_function_closure(func)
137
138 Get the closure (list of cells) associated with *func*. This is equivalent
139 to ``func.__closure__`` on Python 2.6+ and ``func.func_closure`` on Python
140 2.5.
141
142
143 .. function:: get_function_code(func)
144
145 Get the code object associated with *func*. This is equivalent to
146 ``func.__code__`` on Python 2.6+ and ``func.func_code`` on Python 2.5.
147
148
149 .. function:: get_function_defaults(func)
150
151 Get the defaults tuple associated with *func*. This is equivalent to
152 ``func.__defaults__`` on Python 2.6+ and ``func.func_defaults`` on Python
153 2.5.
154
155
156 .. function:: get_function_globals(func)
157
158 Get the globals of *func*. This is equivalent to ``func.__globals__`` on
159 Python 2.6+ and ``func.func_globals`` on Python 2.5.
160
161
162 .. function:: next(it)
163 .. function:: advance_iterator(it)
164
165 Get the next item of iterator *it*. :exc:`py3:StopIteration` is raised if
166 the iterator is exhausted. This is a replacement for calling ``it.next()``
167 in Python 2 and ``next(it)`` in Python 3.
168
169
170 .. function:: callable(obj)
171
172 Check if *obj* can be called. Note ``callable`` has returned in Python 3.2,
173 so using six's version is only necessary when supporting Python 3.0 or 3.1.
174
175
176 .. function:: iterkeys(dictionary, **kwargs)
177
178 Returns an iterator over *dictionary*\'s keys. This replaces
179 ``dictionary.iterkeys()`` on Python 2 and ``dictionary.keys()`` on
180 Python 3. *kwargs* are passed through to the underlying method.
181
182
183 .. function:: itervalues(dictionary, **kwargs)
184
185 Returns an iterator over *dictionary*\'s values. This replaces
186 ``dictionary.itervalues()`` on Python 2 and ``dictionary.values()`` on
187 Python 3. *kwargs* are passed through to the underlying method.
188
189
190 .. function:: iteritems(dictionary, **kwargs)
191
192 Returns an iterator over *dictionary*\'s items. This replaces
193 ``dictionary.iteritems()`` on Python 2 and ``dictionary.items()`` on
194 Python 3. *kwargs* are passed through to the underlying method.
195
196
197 .. function:: iterlists(dictionary, **kwargs)
198
199 Calls ``dictionary.iterlists()`` on Python 2 and ``dictionary.lists()`` on
200 Python 3. No builtin Python mapping type has such a method; this method is
201 intended for use with multi-valued dictionaries like `Werkzeug's
202 <http://werkzeug.pocoo.org/docs/datastructures/#werkzeug.datastructures.Multi Dict>`_.
203 *kwargs* are passed through to the underlying method.
204
205
206 .. function:: create_bound_method(func, obj)
207
208 Return a method object wrapping *func* and bound to *obj*. On both Python 2
209 and 3, this will return a :func:`py3:types.MethodType` object. The reason
210 this wrapper exists is that on Python 2, the ``MethodType`` constructor
211 requires the *obj*'s class to be passed.
212
213
214 .. class:: Iterator
215
216 A class for making portable iterators. The intention is that it be subclassed
217 and subclasses provide a ``__next__`` method. In Python 2, :class:`Iterator`
218 has one method: ``next``. It simply delegates to ``__next__``. An alternate
219 way to do this would be to simply alias ``next`` to ``__next__``. However,
220 this interacts badly with subclasses that override
221 ``__next__``. :class:`Iterator` is empty on Python 3. (In fact, it is just
222 aliased to :class:`py3:object`.)
223
224
225 .. function:: wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=fun ctools.WRAPPER_UPDATES)
226
227 This is exactly the :func:`py3:functools.wraps` decorator, but it sets the
228 ``__wrapped__`` attribute on what it decorates as :func:`py3:functools.wraps`
229 does on Python versions after 3.2.
230
231
232 Syntax compatibility
233 >>>>>>>>>>>>>>>>>>>>
234
235 These functions smooth over operations which have different syntaxes between
236 Python 2 and 3.
237
238
239 .. function:: exec_(code, globals=None, locals=None)
240
241 Execute *code* in the scope of *globals* and *locals*. *code* can be a
242 string or a code object. If *globals* or *locals* are not given, they will
243 default to the scope of the caller. If just *globals* is given, it will also
244 be used as *locals*.
245
246 .. note::
247
248 Python 3's :func:`py3:exec` doesn't take keyword arguments, so calling
249 :func:`exec` with them should be avoided.
250
251
252 .. function:: print_(*args, *, file=sys.stdout, end="\\n", sep=" ")
253
254 Print *args* into *file*. Each argument will be separated with *sep* and
255 *end* will be written to the file after the last argument is printed.
256
257 .. note::
258
259 In Python 2, this function imitates Python 3's :func:`py3:print` by not
260 having softspace support. If you don't know what that is, you're probably
261 ok. :)
262
263
264 .. function:: reraise(exc_type, exc_value, exc_traceback=None)
265
266 Reraise an exception, possibly with a different traceback. In the simple
267 case, ``reraise(*sys.exc_info())`` with an active exception (in an except
268 block) reraises the current exception with the last traceback. A different
269 traceback can be specified with the *exc_traceback* parameter. Note that
270 since the exception reraising is done within the :func:`reraise` function,
271 Python will attach the call frame of :func:`reraise` to whatever traceback is
272 raised.
273
274
275 .. function:: with_metaclass(metaclass, *bases)
276
277 Create a new class with base classes *bases* and metaclass *metaclass*. This
278 is designed to be used in class declarations like this: ::
279
280 from six import with_metaclass
281
282 class Meta(type):
283 pass
284
285 class Base(object):
286 pass
287
288 class MyClass(with_metaclass(Meta, Base)):
289 pass
290
291 Another way to set a metaclass on a class is with the :func:`add_metaclass`
292 decorator.
293
294
295 .. function:: add_metaclass(metaclass)
296
297 Class decorator that replaces a normally-constructed class with a
298 metaclass-constructed one. Example usage: ::
299
300 @add_metaclass(Meta)
301 class MyClass(object):
302 pass
303
304 That code produces a class equivalent to ::
305
306 class MyClass(object, metaclass=Meta):
307 pass
308
309 on Python 3 or ::
310
311 class MyClass(object):
312 __metaclass__ = MyMeta
313
314 on Python 2.
315
316 Note that class decorators require Python 2.6. However, the effect of the
317 decorator can be emulated on Python 2.5 like so::
318
319 class MyClass(object):
320 pass
321 MyClass = add_metaclass(Meta)(MyClass)
322
323
324 Binary and text data
325 >>>>>>>>>>>>>>>>>>>>
326
327 Python 3 enforces the distinction between byte strings and text strings far more
328 rigoriously than Python 2 does; binary data cannot be automatically coerced to
329 or from text data. six provides several functions to assist in classifying
330 string data in all Python versions.
331
332
333 .. function:: b(data)
334
335 A "fake" bytes literal. *data* should always be a normal string literal. In
336 Python 2, :func:`b` returns a 8-bit string. In Python 3, *data* is encoded
337 with the latin-1 encoding to bytes.
338
339
340 .. note::
341
342 Since all Python versions 2.6 and after support the ``b`` prefix,
343 :func:`b`, code without 2.5 support doesn't need :func:`b`.
344
345
346 .. function:: u(text)
347
348 A "fake" unicode literal. *text* should always be a normal string literal.
349 In Python 2, :func:`u` returns unicode, and in Python 3, a string. Also, in
350 Python 2, the string is decoded with the ``unicode-escape`` codec, which
351 allows unicode escapes to be used in it.
352
353
354 .. note::
355
356 In Python 3.3, the ``u`` prefix has been reintroduced. Code that only
357 supports Python 3 versions greater than 3.3 thus does not need
358 :func:`u`.
359
360 .. note::
361
362 On Python 2, :func:`u` doesn't know what the encoding of the literal
363 is. Each byte is converted directly to the unicode codepoint of the same
364 value. Because of this, it's only safe to use :func:`u` with strings of
365 ASCII data.
366
367
368 .. function:: unichr(c)
369
370 Return the (Unicode) string representing the codepoint *c*. This is
371 equivalent to :func:`py2:unichr` on Python 2 and :func:`py3:chr` on Python 3.
372
373
374 .. function:: int2byte(i)
375
376 Converts *i* to a byte. *i* must be in ``range(0, 256)``. This is
377 equivalent to :func:`py2:chr` in Python 2 and ``bytes((i,))`` in Python 3.
378
379
380 .. function:: byte2int(bs)
381
382 Converts the first byte of *bs* to an integer. This is equivalent to
383 ``ord(bs[0])`` on Python 2 and ``bs[0]`` on Python 3.
384
385
386 .. function:: indexbytes(buf, i)
387
388 Return the byte at index *i* of *buf* as an integer. This is equivalent to
389 indexing a bytes object in Python 3.
390
391
392 .. function:: iterbytes(buf)
393
394 Return an iterator over bytes in *buf* as integers. This is equivalent to
395 a bytes object iterator in Python 3.
396
397
398 .. data:: StringIO
399
400 This is an fake file object for textual data. It's an alias for
401 :class:`py2:StringIO.StringIO` in Python 2 and :class:`py3:io.StringIO` in
402 Python 3.
403
404
405 .. data:: BytesIO
406
407 This is a fake file object for binary data. In Python 2, it's an alias for
408 :class:`py2:StringIO.StringIO`, but in Python 3, it's an alias for
409 :class:`py3:io.BytesIO`.
410
411
412 Renamed modules and attributes compatibility
413 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
414
415 .. module:: six.moves
416 :synopsis: Renamed modules and attributes compatibility
417
418 Python 3 reorganized the standard library and moved several functions to
419 different modules. Six provides a consistent interface to them through the fake
420 :mod:`six.moves` module. For example, to load the module for parsing HTML on
421 Python 2 or 3, write::
422
423 from six.moves import html_parser
424
425 Similarly, to get the function to reload modules, which was moved from the
426 builtin module to the ``imp`` module, use::
427
428 from six.moves import reload_module
429
430 For the most part, :mod:`six.moves` aliases are the names of the modules in
431 Python 3. When the new Python 3 name is a package, the components of the name
432 are separated by underscores. For example, ``html.parser`` becomes
433 ``html_parser``. In some cases where several modules have been combined, the
434 Python 2 name is retained. This is so the appropiate modules can be found when
435 running on Python 2. For example, ``BaseHTTPServer`` which is in
436 ``http.server`` in Python 3 is aliased as ``BaseHTTPServer``.
437
438 Some modules which had two implementations have been merged in Python 3. For
439 example, ``cPickle`` no longer exists in Python 3; it was merged with
440 ``pickle``. In these cases, fetching the fast version will load the fast one on
441 Python 2 and the merged module in Python 3.
442
443 The :mod:`py2:urllib`, :mod:`py2:urllib2`, and :mod:`py2:urlparse` modules have
444 been combined in the :mod:`py3:urllib` package in Python 3. The
445 :mod:`six.moves.urllib` package is a version-independent location for this
446 functionality; its structure mimics the structure of the Python 3
447 :mod:`py3:urllib` package.
448
449 .. note::
450
451 In order to make imports of the form::
452
453 from six.moves.cPickle import loads
454
455 work, six places special proxy objects in in :data:`py3:sys.modules`. These
456 proxies lazily load the underlying module when an attribute is fetched. This
457 will fail if the underlying module is not available in the Python
458 interpreter. For example, ``sys.modules["six.moves.winreg"].LoadKey`` would
459 fail on any non-Windows platform. Unfortunately, some applications try to
460 load attributes on every module in :data:`py3:sys.modules`. six mitigates
461 this problem for some applications by pretending attributes on unimportable
462 modules don't exist. This hack doesn't work in every case, though. If you are
463 encountering problems with the lazy modules and don't use any from imports
464 directly from ``six.moves`` modules, you can workaround the issue by removing
465 the six proxy modules::
466
467 d = [name for name in sys.modules if name.startswith("six.moves.")]
468 for name in d:
469 del sys.modules[name]
470
471 Supported renames:
472
473 +------------------------------+-------------------------------------+---------- ---------------------------+
474 | Name | Python 2 name | Python 3 name |
475 +==============================+=====================================+========== ===========================+
476 | ``builtins`` | :mod:`py2:__builtin__` | :mod:`py3 :builtins` |
477 +------------------------------+-------------------------------------+---------- ---------------------------+
478 | ``configparser`` | :mod:`py2:ConfigParser` | :mod:`py3 :configparser` |
479 +------------------------------+-------------------------------------+---------- ---------------------------+
480 | ``copyreg`` | :mod:`py2:copy_reg` | :mod:`py3 :copyreg` |
481 +------------------------------+-------------------------------------+---------- ---------------------------+
482 | ``cPickle`` | :mod:`py2:cPickle` | :mod:`py3 :pickle` |
483 +------------------------------+-------------------------------------+---------- ---------------------------+
484 | ``cStringIO`` | :func:`py2:cStringIO.StringIO` | :class:`p y3:io.StringIO` |
485 +------------------------------+-------------------------------------+---------- ---------------------------+
486 | ``dbm_gnu`` | :func:`py2:gdbm` | :class:`p y3:dbm.gnu` |
487 +------------------------------+-------------------------------------+---------- ---------------------------+
488 | ``_dummy_thread`` | :mod:`py2:dummy_thread` | :mod:`py3 :_dummy_thread` |
489 +------------------------------+-------------------------------------+---------- ---------------------------+
490 | ``email_mime_multipart`` | :mod:`py2:email.MIMEMultipart` | :mod:`py3 :email.mime.multipart` |
491 +------------------------------+-------------------------------------+---------- ---------------------------+
492 | ``email_mime_nonmultipart`` | :mod:`py2:email.MIMENonMultipart` | :mod:`py3 :email.mime.nonmultipart` |
493 +------------------------------+-------------------------------------+---------- ---------------------------+
494 | ``email_mime_text`` | :mod:`py2:email.MIMEText` | :mod:`py3 :email.mime.text` |
495 +------------------------------+-------------------------------------+---------- ---------------------------+
496 | ``email_mime_base`` | :mod:`py2:email.MIMEBase` | :mod:`py3 :email.mime.base` |
497 +------------------------------+-------------------------------------+---------- ---------------------------+
498 | ``filter`` | :func:`py2:itertools.ifilter` | :func:`py 3:filter` |
499 +------------------------------+-------------------------------------+---------- ---------------------------+
500 | ``filterfalse`` | :func:`py2:itertools.ifilterfalse` | :func:`py 3:itertools.filterfalse` |
501 +------------------------------+-------------------------------------+---------- ---------------------------+
502 | ``http_cookiejar`` | :mod:`py2:cookielib` | :mod:`py3 :http.cookiejar` |
503 +------------------------------+-------------------------------------+---------- ---------------------------+
504 | ``http_cookies`` | :mod:`py2:Cookie` | :mod:`py3 :http.cookies` |
505 +------------------------------+-------------------------------------+---------- ---------------------------+
506 | ``html_entities`` | :mod:`py2:htmlentitydefs` | :mod:`py3 :html.entities` |
507 +------------------------------+-------------------------------------+---------- ---------------------------+
508 | ``html_parser`` | :mod:`py2:HTMLParser` | :mod:`py3 :html.parser` |
509 +------------------------------+-------------------------------------+---------- ---------------------------+
510 | ``http_client`` | :mod:`py2:httplib` | :mod:`py3 :http.client` |
511 +------------------------------+-------------------------------------+---------- ---------------------------+
512 | ``BaseHTTPServer`` | :mod:`py2:BaseHTTPServer` | :mod:`py3 :http.server` |
513 +------------------------------+-------------------------------------+---------- ---------------------------+
514 | ``CGIHTTPServer`` | :mod:`py2:CGIHTTPServer` | :mod:`py3 :http.server` |
515 +------------------------------+-------------------------------------+---------- ---------------------------+
516 | ``SimpleHTTPServer`` | :mod:`py2:SimpleHTTPServer` | :mod:`py3 :http.server` |
517 +------------------------------+-------------------------------------+---------- ---------------------------+
518 | ``input`` | :func:`py2:raw_input` | :func:`py 3:input` |
519 +------------------------------+-------------------------------------+---------- ---------------------------+
520 | ``intern`` | :func:`py2:intern` | :func:`py 3:sys.intern` |
521 +------------------------------+-------------------------------------+---------- ---------------------------+
522 | ``map`` | :func:`py2:itertools.imap` | :func:`py 3:map` |
523 +------------------------------+-------------------------------------+---------- ---------------------------+
524 | ``queue`` | :mod:`py2:Queue` | :mod:`py3 :queue` |
525 +------------------------------+-------------------------------------+---------- ---------------------------+
526 | ``range`` | :func:`py2:xrange` | :func:`py 3:range` |
527 +------------------------------+-------------------------------------+---------- ---------------------------+
528 | ``reduce`` | :func:`py2:reduce` | :func:`py 3:functools.reduce` |
529 +------------------------------+-------------------------------------+---------- ---------------------------+
530 | ``reload_module`` | :func:`py2:reload` | :func:`py 3:imp.reload` |
531 +------------------------------+-------------------------------------+---------- ---------------------------+
532 | ``reprlib`` | :mod:`py2:repr` | :mod:`py3 :reprlib` |
533 +------------------------------+-------------------------------------+---------- ---------------------------+
534 | ``shlex_quote`` | :mod:`py2:pipes.quote` | :mod:`py3 :shlex.quote` |
535 +------------------------------+-------------------------------------+---------- ---------------------------+
536 | ``socketserver`` | :mod:`py2:SocketServer` | :mod:`py3 :socketserver` |
537 +------------------------------+-------------------------------------+---------- ---------------------------+
538 | ``_thread`` | :mod:`py2:thread` | :mod:`py3 :_thread` |
539 +------------------------------+-------------------------------------+---------- ---------------------------+
540 | ``tkinter`` | :mod:`py2:Tkinter` | :mod:`py3 :tkinter` |
541 +------------------------------+-------------------------------------+---------- ---------------------------+
542 | ``tkinter_dialog`` | :mod:`py2:Dialog` | :mod:`py3 :tkinter.dialog` |
543 +------------------------------+-------------------------------------+---------- ---------------------------+
544 | ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3 :tkinter.FileDialog` |
545 +------------------------------+-------------------------------------+---------- ---------------------------+
546 | ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3 :tkinter.scrolledtext` |
547 +------------------------------+-------------------------------------+---------- ---------------------------+
548 | ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py3 :tkinter.simpledialog` |
549 +------------------------------+-------------------------------------+---------- ---------------------------+
550 | ``tkinter_ttk`` | :mod:`py2:ttk` | :mod:`py3 :tkinter.ttk` |
551 +------------------------------+-------------------------------------+---------- ---------------------------+
552 | ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3 :tkinter.tix` |
553 +------------------------------+-------------------------------------+---------- ---------------------------+
554 | ``tkinter_constants`` | :mod:`py2:Tkconstants` | :mod:`py3 :tkinter.constants` |
555 +------------------------------+-------------------------------------+---------- ---------------------------+
556 | ``tkinter_dnd`` | :mod:`py2:Tkdnd` | :mod:`py3 :tkinter.dnd` |
557 +------------------------------+-------------------------------------+---------- ---------------------------+
558 | ``tkinter_colorchooser`` | :mod:`py2:tkColorChooser` | :mod:`py3 :tkinter.colorchooser` |
559 +------------------------------+-------------------------------------+---------- ---------------------------+
560 | ``tkinter_commondialog`` | :mod:`py2:tkCommonDialog` | :mod:`py3 :tkinter.commondialog` |
561 +------------------------------+-------------------------------------+---------- ---------------------------+
562 | ``tkinter_tkfiledialog`` | :mod:`py2:tkFileDialog` | :mod:`py3 :tkinter.filedialog` |
563 +------------------------------+-------------------------------------+---------- ---------------------------+
564 | ``tkinter_font`` | :mod:`py2:tkFont` | :mod:`py3 :tkinter.font` |
565 +------------------------------+-------------------------------------+---------- ---------------------------+
566 | ``tkinter_messagebox`` | :mod:`py2:tkMessageBox` | :mod:`py3 :tkinter.messagebox` |
567 +------------------------------+-------------------------------------+---------- ---------------------------+
568 | ``tkinter_tksimpledialog`` | :mod:`py2:tkSimpleDialog` | :mod:`py3 :tkinter.simpledialog` |
569 +------------------------------+-------------------------------------+---------- ---------------------------+
570 | ``urllib.parse`` | See :mod:`six.moves.urllib.parse` | :mod:`py3 :urllib.parse` |
571 +------------------------------+-------------------------------------+---------- ---------------------------+
572 | ``urllib.error`` | See :mod:`six.moves.urllib.error` | :mod:`py3 :urllib.error` |
573 +------------------------------+-------------------------------------+---------- ---------------------------+
574 | ``urllib.request`` | See :mod:`six.moves.urllib.request` | :mod:`py3 :urllib.request` |
575 +------------------------------+-------------------------------------+---------- ---------------------------+
576 | ``urllib.response`` | See :mod:`six.moves.urllib.response`| :mod:`py3 :urllib.response` |
577 +------------------------------+-------------------------------------+---------- ---------------------------+
578 | ``urllib.robotparser`` | :mod:`py2:robotparser` | :mod:`py3 :urllib.robotparser` |
579 +------------------------------+-------------------------------------+---------- ---------------------------+
580 | ``urllib_robotparser`` | :mod:`py2:robotparser` | :mod:`py3 :urllib.robotparser` |
581 +------------------------------+-------------------------------------+---------- ---------------------------+
582 | ``UserDict`` | :class:`py2:UserDict.UserDict` | :class:`p y3:collections.UserDict` |
583 +------------------------------+-------------------------------------+---------- ---------------------------+
584 | ``UserList`` | :class:`py2:UserList.UserList` | :class:`p y3:collections.UserList` |
585 +------------------------------+-------------------------------------+---------- ---------------------------+
586 | ``UserString`` | :class:`py2:UserString.UserString` | :class:`p y3:collections.UserString` |
587 +------------------------------+-------------------------------------+---------- ---------------------------+
588 | ``winreg`` | :mod:`py2:_winreg` | :mod:`py3 :winreg` |
589 +------------------------------+-------------------------------------+---------- ---------------------------+
590 | ``xmlrpc_client`` | :mod:`py2:xmlrpclib` | :mod:`py3 :xmlrpc.client` |
591 +------------------------------+-------------------------------------+---------- ---------------------------+
592 | ``xmlrpc_server`` | :mod:`py2:SimpleXMLRPCServer` | :mod:`py3 :xmlrpc.server` |
593 +------------------------------+-------------------------------------+---------- ---------------------------+
594 | ``xrange`` | :func:`py2:xrange` | :func:`py 3:range` |
595 +------------------------------+-------------------------------------+---------- ---------------------------+
596 | ``zip`` | :func:`py2:itertools.izip` | :func:`py 3:zip` |
597 +------------------------------+-------------------------------------+---------- ---------------------------+
598 | ``zip_longest`` | :func:`py2:itertools.izip_longest` | :func:`py 3:itertools.zip_longest` |
599 +------------------------------+-------------------------------------+---------- ---------------------------+
600
601 urllib parse
602 <<<<<<<<<<<<
603
604 .. module:: six.moves.urllib.parse
605 :synopsis: Stuff from :mod:`py2:urlparse` and :mod:`py2:urllib` in Python 2 a nd :mod:`py3:urllib.parse` in Python 3
606
607 Contains functions from Python 3's :mod:`py3:urllib.parse` and Python 2's:
608
609 :mod:`py2:urlparse`:
610
611 * :func:`py2:urlparse.ParseResult`
612 * :func:`py2:urlparse.SplitResult`
613 * :func:`py2:urlparse.urlparse`
614 * :func:`py2:urlparse.urlunparse`
615 * :func:`py2:urlparse.parse_qs`
616 * :func:`py2:urlparse.parse_qsl`
617 * :func:`py2:urlparse.urljoin`
618 * :func:`py2:urlparse.urldefrag`
619 * :func:`py2:urlparse.urlsplit`
620 * :func:`py2:urlparse.urlunsplit`
621 * :func:`py2:urlparse.splitquery`
622 * :func:`py2:urlparse.uses_fragment`
623 * :func:`py2:urlparse.uses_netloc`
624 * :func:`py2:urlparse.uses_params`
625 * :func:`py2:urlparse.uses_query`
626 * :func:`py2:urlparse.uses_relative`
627
628 and :mod:`py2:urllib`:
629
630 * :func:`py2:urllib.quote`
631 * :func:`py2:urllib.quote_plus`
632 * :func:`py2:urllib.splittag`
633 * :func:`py2:urllib.splituser`
634 * :func:`py2:urllib.unquote`
635 * :func:`py2:urllib.unquote_plus`
636 * :func:`py2:urllib.urlencode`
637
638
639 urllib error
640 <<<<<<<<<<<<
641
642 .. module:: six.moves.urllib.error
643 :synopsis: Stuff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 an d :mod:`py3:urllib.error` in Python 3
644
645 Contains exceptions from Python 3's :mod:`py3:urllib.error` and Python 2's:
646
647 :mod:`py2:urllib`:
648
649 * :exc:`py2:urllib.ContentTooShortError`
650
651 and :mod:`py2:urllib2`:
652
653 * :exc:`py2:urllib2.URLError`
654 * :exc:`py2:urllib2.HTTPError`
655
656
657 urllib request
658 <<<<<<<<<<<<<<
659
660 .. module:: six.moves.urllib.request
661 :synopsis: Stuff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 an d :mod:`py3:urllib.request` in Python 3
662
663 Contains items from Python 3's :mod:`py3:urllib.request` and Python 2's:
664
665 :mod:`py2:urllib`:
666
667 * :func:`py2:urllib.pathname2url`
668 * :func:`py2:urllib.url2pathname`
669 * :func:`py2:urllib.getproxies`
670 * :func:`py2:urllib.urlretrieve`
671 * :func:`py2:urllib.urlcleanup`
672 * :class:`py2:urllib.URLopener`
673 * :class:`py2:urllib.FancyURLopener`
674 * :func:`py2:urllib.proxy_bypass`
675
676 and :mod:`py2:urllib2`:
677
678 * :func:`py2:urllib2.urlopen`
679 * :func:`py2:urllib2.install_opener`
680 * :func:`py2:urllib2.build_opener`
681 * :class:`py2:urllib2.Request`
682 * :class:`py2:urllib2.OpenerDirector`
683 * :class:`py2:urllib2.HTTPDefaultErrorHandler`
684 * :class:`py2:urllib2.HTTPRedirectHandler`
685 * :class:`py2:urllib2.HTTPCookieProcessor`
686 * :class:`py2:urllib2.ProxyHandler`
687 * :class:`py2:urllib2.BaseHandler`
688 * :class:`py2:urllib2.HTTPPasswordMgr`
689 * :class:`py2:urllib2.HTTPPasswordMgrWithDefaultRealm`
690 * :class:`py2:urllib2.AbstractBasicAuthHandler`
691 * :class:`py2:urllib2.HTTPBasicAuthHandler`
692 * :class:`py2:urllib2.ProxyBasicAuthHandler`
693 * :class:`py2:urllib2.AbstractDigestAuthHandler`
694 * :class:`py2:urllib2.HTTPDigestAuthHandler`
695 * :class:`py2:urllib2.ProxyDigestAuthHandler`
696 * :class:`py2:urllib2.HTTPHandler`
697 * :class:`py2:urllib2.HTTPSHandler`
698 * :class:`py2:urllib2.FileHandler`
699 * :class:`py2:urllib2.FTPHandler`
700 * :class:`py2:urllib2.CacheFTPHandler`
701 * :class:`py2:urllib2.UnknownHandler`
702 * :class:`py2:urllib2.HTTPErrorProcessor`
703
704
705 urllib response
706 <<<<<<<<<<<<<<<
707
708 .. module:: six.moves.urllib.response
709 :synopsis: Stuff from :mod:`py2:urllib` in Python 2 and :mod:`py3:urllib.resp onse` in Python 3
710
711 Contains classes from Python 3's :mod:`py3:urllib.response` and Python 2's:
712
713 :mod:`py2:urllib`:
714
715 * :class:`py2:urllib.addbase`
716 * :class:`py2:urllib.addclosehook`
717 * :class:`py2:urllib.addinfo`
718 * :class:`py2:urllib.addinfourl`
719
720
721 Advanced - Customizing renames
722 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
723
724 .. currentmodule:: six
725
726 It is possible to add additional names to the :mod:`six.moves` namespace.
727
728
729 .. function:: add_move(item)
730
731 Add *item* to the :mod:`six.moves` mapping. *item* should be a
732 :class:`MovedAttribute` or :class:`MovedModule` instance.
733
734
735 .. function:: remove_move(name)
736
737 Remove the :mod:`six.moves` mapping called *name*. *name* should be a
738 string.
739
740
741 Instances of the following classes can be passed to :func:`add_move`. Neither
742 have any public members.
743
744
745 .. class:: MovedModule(name, old_mod, new_mod)
746
747 Create a mapping for :mod:`six.moves` called *name* that references different
748 modules in Python 2 and 3. *old_mod* is the name of the Python 2 module.
749 *new_mod* is the name of the Python 3 module.
750
751
752 .. class:: MovedAttribute(name, old_mod, new_mod, old_attr=None, new_attr=None)
753
754 Create a mapping for :mod:`six.moves` called *name* that references different
755 attributes in Python 2 and 3. *old_mod* is the name of the Python 2 module.
756 *new_mod* is the name of the Python 3 module. If *new_attr* is not given, it
757 defaults to *old_attr*. If neither is given, they both default to *name*.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698