• Home
  • Raw
  • Download

Lines Matching refs:Python

1 Six: Python 2 and 3 Compatibility Library
5 :synopsis: Python 2 and 3 compatibility
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
36 A boolean indicating if the code is running on Python 2.
40 A boolean indicating if the code is running on Python 3.
46 Six provides constants that may differ between Python versions. Ones ending
53 Possible class types. In Python 2, this encompasses old-style and new-style
54 classes. In Python 3, this is just new-styles.
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`.
65 Possible types for text data. This is :func:`py2:basestring` in Python 2 and
66 :func:`py3:str` in Python 3.
72 Python 2 and :func:`py3:str` in Python 3.
77 Type for representing binary data. This is :func:`py2:str` in Python 2 and
78 :func:`py3:bytes` in Python 3.
84 This is equivalent to :data:`py3:sys.maxsize` in Python 2.6 and later
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
107 Python 3 renamed the attributes of several interpreter data structures. The
114 Get the function out of unbound method *meth*. In Python 3, unbound methods
139 to ``func.__closure__`` on Python 2.6+ and ``func.func_closure`` on Python
146 ``func.__code__`` on Python 2.6+ and ``func.func_code`` on Python 2.5.
152 ``func.__defaults__`` on Python 2.6+ and ``func.func_defaults`` on Python
159 Python 2.6+ and ``func.func_globals`` on Python 2.5.
167 in Python 2 and ``next(it)`` in Python 3. Python 2.6 and above have a
168 builtin ``next`` function, so six's version is only necessary for Python 2.5
174 Check if *obj* can be called. Note ``callable`` has returned in Python 3.2,
175 so using six's version is only necessary when supporting Python 3.0 or 3.1.
181 ``dictionary.iterkeys()`` on Python 2 and ``dictionary.keys()`` on
182 Python 3. *kwargs* are passed through to the underlying method.
188 ``dictionary.itervalues()`` on Python 2 and ``dictionary.values()`` on
189 Python 3. *kwargs* are passed through to the underlying method.
195 ``dictionary.iteritems()`` on Python 2 and ``dictionary.items()`` on
196 Python 3. *kwargs* are passed through to the underlying method.
201 Calls ``dictionary.iterlists()`` on Python 2 and ``dictionary.lists()`` on
202 Python 3. No builtin Python mapping type has such a method; this method is
211 :meth:`py2:dict.viewkeys` on Python 2.7 and :meth:`py3:dict.keys` on
212 Python 3.
218 :meth:`py2:dict.viewvalues` on Python 2.7 and :meth:`py3:dict.values` on
219 Python 3.
225 :meth:`py2:dict.viewitems` on Python 2.7 and :meth:`py3:dict.items` on
226 Python 3.
231 Return a method object wrapping *func* and bound to *obj*. On both Python 2
233 this wrapper exists is that on Python 2, the ``MethodType`` constructor
239 Return an unbound method object wrapping *func*. In Python 2, this will
240 return a :func:`py2:types.MethodType` object. In Python 3, unbound methods
247 and subclasses provide a ``__next__`` method. In Python 2, :class:`Iterator`
251 ``__next__``. :class:`Iterator` is empty on Python 3. (In fact, it is just
259 does on Python versions after 3.2.
266 Python 2 and 3.
278 Python 3's :func:`py3:exec` doesn't take keyword arguments, so calling
290 In Python 2, this function imitates Python 3's :func:`py3:print` by not
297 Raise an exception from a context. On Python 3, this is equivalent to
298 ``raise exc_value from exc_value_from``. On Python 2, which does not support
309 Python will attach the call frame of :func:`reraise` to whatever traceback is
347 on Python 3 or ::
352 on Python 2.
354 Note that class decorators require Python 2.6. However, the effect of the
355 decorator can be emulated on Python 2.5 like so::
365 Python 3 enforces the distinction between byte strings and text strings far more
366 rigorously than Python 2 does; binary data cannot be automatically coerced to
368 string data in all Python versions.
374 Python 2, :func:`b` returns a 8-bit string. In Python 3, *data* is encoded
380 Since all Python versions 2.6 and after support the ``b`` prefix,
387 In Python 2, :func:`u` returns unicode, and in Python 3, a string. Also, in
388 Python 2, the string is decoded with the ``unicode-escape`` codec, which
394 In Python 3.3, the ``u`` prefix has been reintroduced. Code that only
395 supports Python 3 versions of 3.3 and higher thus does not need
400 On Python 2, :func:`u` doesn't know what the encoding of the literal
409 equivalent to :func:`py2:unichr` on Python 2 and :func:`py3:chr` on Python 3.
415 equivalent to :func:`py2:chr` in Python 2 and ``bytes((i,))`` in Python 3.
421 ``ord(bs[0])`` on Python 2 and ``bs[0]`` on Python 3.
427 indexing a bytes object in Python 3.
433 a bytes object iterator in Python 3.
439 :class:`py2:StringIO.StringIO` in Python 2 and :class:`py3:io.StringIO` in
440 Python 3.
445 This is a fake file object for binary data. In Python 2, it's an alias for
446 :class:`py2:StringIO.StringIO`, but in Python 3, it's an alias for
453 Python 3, the decorator does nothing. On Python 2, it aliases the
472 Note these functions are only available on Python 2.7 or later.
476 Alias for :meth:`~py3:unittest.TestCase.assertCountEqual` on Python 3 and
477 :meth:`~py2:unittest.TestCase.assertItemsEqual` on Python 2.
482 Alias for :meth:`~py3:unittest.TestCase.assertRaisesRegex` on Python 3 and
483 :meth:`~py2:unittest.TestCase.assertRaisesRegexp` on Python 2.
488 Alias for :meth:`~py3:unittest.TestCase.assertRegex` on Python 3 and
489 :meth:`~py2:unittest.TestCase.assertRegexpMatches` on Python 2.
498 Python 3 reorganized the standard library and moved several functions to
501 Python 2 or 3, write::
511 Python 3. When the new Python 3 name is a package, the components of the name
514 Python 2 name is retained. This is so the appropriate modules can be found when
515 running on Python 2. For example, ``BaseHTTPServer`` which is in
516 ``http.server`` in Python 3 is aliased as ``BaseHTTPServer``.
518 Some modules which had two implementations have been merged in Python 3. For
519 example, ``cPickle`` no longer exists in Python 3; it was merged with
521 Python 2 and the merged module in Python 3.
524 been combined in the :mod:`py3:urllib` package in Python 3. The
526 functionality; its structure mimics the structure of the Python 3
537 will fail if the underlying module is not available in the Python
554 | Name | Python 2 name | Python 3 name …
620 | | | on Python 3.4+ …
695 …ff from :mod:`py2:urlparse` and :mod:`py2:urllib` in Python 2 and :mod:`py3:urllib.parse` in Pytho…
697 Contains functions from Python 3's :mod:`py3:urllib.parse` and Python 2's:
734 …uff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 and :mod:`py3:urllib.error` in Pytho…
736 Contains exceptions from Python 3's :mod:`py3:urllib.error` and Python 2's:
752 …ff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 and :mod:`py3:urllib.request` in Pyth…
754 Contains items from Python 3's :mod:`py3:urllib.request` and Python 2's:
802 :synopsis: Stuff from :mod:`py2:urllib` in Python 2 and :mod:`py3:urllib.response` in Python 3
804 Contains classes from Python 3's :mod:`py3:urllib.response` and Python 2's:
841 modules in Python 2 and 3. *old_mod* is the name of the Python 2 module.
842 *new_mod* is the name of the Python 3 module.
848 attributes in Python 2 and 3. *old_mod* is the name of the Python 2 module.
849 *new_mod* is the name of the Python 3 module. If *new_attr* is not given, it