• Home
  • Raw
  • Download

Lines Matching +full:py3 +full:- +full:six

1 Six: Python 2 and 3 Compatibility Library
4 .. module:: six
11 Six provides simple utilities for wrapping over differences between Python 2 and
13 without modification. six consists of only one Python file, so it is painless
16 Six can be downloaded on `PyPi <https://pypi.python.org/pypi/six/>`_. Its bug
17 tracker and code hosting is on `GitHub <https://github.com/benjaminp/six>`_.
19 The name, "six", comes from the fact that 2*3 equals 6. Why not addition?
25 ------------------
32 ----------------
38 .. data:: PY3
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.
60 :func:`py2:int`, and in Python 3, just :func:`py3:int`.
66 :func:`py3:str` in Python 3.
72 Python 2 and :func:`py3:str` in Python 3.
78 :func:`py3:bytes` in Python 3.
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
93 import six
96 if isinstance(value, six.integer_types):
98 elif isinstance(value, six.class_types):
100 elif isinstance(value, six.string_types):
109 functions and methods is the stdlib :mod:`py3:inspect` module.
118 from six import get_unbound_function
165 Get the next item of iterator *it*. :exc:`py3:StopIteration` is raised if
168 builtin ``next`` function, so six's version is only necessary for Python 2.5
175 so using six's version is only necessary when supporting Python 3.0 or 3.1.
203 intended for use with multi-valued dictionaries like `Werkzeug's
211 :meth:`py2:dict.viewkeys` on Python 2.7 and :meth:`py3:dict.keys` on
218 :meth:`py2:dict.viewvalues` on Python 2.7 and :meth:`py3:dict.values` on
225 :meth:`py2:dict.viewitems` on Python 2.7 and :meth:`py3:dict.items` on
232 and 3, this will return a :func:`py3:types.MethodType` object. The reason
252 aliased to :class:`py3:object`.)
257 This is exactly the :func:`py3:functools.wraps` decorator, but it sets the
258 ``__wrapped__`` attribute on what it decorates as :func:`py3:functools.wraps`
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
318 from six import with_metaclass
335 Class decorator that replaces a normally-constructed class with a
336 metaclass-constructed one. Example usage: ::
367 or from text data. six provides several functions to assist in classifying
374 Python 2, :func:`b` returns a 8-bit string. In Python 3, *data* is encoded
375 with the latin-1 encoding to bytes.
388 Python 2, the string is decoded with the ``unicode-escape`` codec, which
409 equivalent to :func:`py2:unichr` on Python 2 and :func:`py3:chr` on Python 3.
439 :class:`py2:StringIO.StringIO` in Python 2 and :class:`py3:io.StringIO` in
447 :class:`py3:io.BytesIO`.
455 that returns the result of ``__unicode__()`` encoded with UTF-8.
461 Six contains compatibility shims for unittest assertions that have been renamed.
465 import six
470 six.assertCountEqual(self, (1, 2), [2, 1])
476 Alias for :meth:`~py3:unittest.TestCase.assertCountEqual` on Python 3 and
482 Alias for :meth:`~py3:unittest.TestCase.assertRaisesRegex` on Python 3 and
488 Alias for :meth:`~py3:unittest.TestCase.assertRegex` on Python 3 and
495 .. module:: six.moves
499 different modules. Six provides a consistent interface to them through the fake
500 :mod:`six.moves` module. For example, to load the module for parsing HTML on
503 from six.moves import html_parser
508 from six.moves import reload_module
510 For the most part, :mod:`six.moves` aliases are the names of the modules in
524 been combined in the :mod:`py3:urllib` package in Python 3. The
525 :mod:`six.moves.urllib` package is a version-independent location for this
527 :mod:`py3:urllib` package.
533 from six.moves.cPickle import loads
535 work, six places special proxy objects in :data:`py3:sys.modules`. These
538 interpreter. For example, ``sys.modules["six.moves.winreg"].LoadKey`` would
539 fail on any non-Windows platform. Unfortunately, some applications try to
540 load attributes on every module in :data:`py3:sys.modules`. six mitigates
544 directly from ``six.moves`` modules, you can workaround the issue by removing
545 the six proxy modules::
547 d = [name for name in sys.modules if name.startswith("six.moves.")]
553 +------------------------------+-------------------------------------+-----------------------------…
556 | ``builtins`` | :mod:`py2:__builtin__` | :mod:`py3:builtins` …
557 +------------------------------+-------------------------------------+-----------------------------…
558 | ``configparser`` | :mod:`py2:ConfigParser` | :mod:`py3:configparser` …
559 +------------------------------+-------------------------------------+-----------------------------…
560 | ``copyreg`` | :mod:`py2:copy_reg` | :mod:`py3:copyreg` …
561 +------------------------------+-------------------------------------+-----------------------------…
562 | ``cPickle`` | :mod:`py2:cPickle` | :mod:`py3:pickle` …
563 +------------------------------+-------------------------------------+-----------------------------…
564 | ``cStringIO`` | :func:`py2:cStringIO.StringIO` | :class:`py3:io.StringIO` …
565 +------------------------------+-------------------------------------+-----------------------------…
566 | ``dbm_gnu`` | :func:`py2:gdbm` | :class:`py3:dbm.gnu` …
567 +------------------------------+-------------------------------------+-----------------------------…
568 | ``_dummy_thread`` | :mod:`py2:dummy_thread` | :mod:`py3:_dummy_thread` …
569 +------------------------------+-------------------------------------+-----------------------------…
570 | ``email_mime_base`` | :mod:`py2:email.MIMEBase` | :mod:`py3:email.mime.base` …
571 +------------------------------+-------------------------------------+-----------------------------…
572 | ``email_mime_image`` | :mod:`py2:email.MIMEImage` | :mod:`py3:email.mime.image` …
573 +------------------------------+-------------------------------------+-----------------------------…
574 | ``email_mime_multipart`` | :mod:`py2:email.MIMEMultipart` | :mod:`py3:email.mime.multipa…
575 +------------------------------+-------------------------------------+-----------------------------…
576 | ``email_mime_nonmultipart`` | :mod:`py2:email.MIMENonMultipart` | :mod:`py3:email.mime.nonmult…
577 +------------------------------+-------------------------------------+-----------------------------…
578 | ``email_mime_text`` | :mod:`py2:email.MIMEText` | :mod:`py3:email.mime.text` …
579 +------------------------------+-------------------------------------+-----------------------------…
580 | ``filter`` | :func:`py2:itertools.ifilter` | :func:`py3:filter` …
581 +------------------------------+-------------------------------------+-----------------------------…
582 | ``filterfalse`` | :func:`py2:itertools.ifilterfalse` | :func:`py3:itertools.filterf…
583 +------------------------------+-------------------------------------+-----------------------------…
584 | ``getcwd`` | :func:`py2:os.getcwdu` | :func:`py3:os.getcwd` …
585 +------------------------------+-------------------------------------+-----------------------------…
586 | ``getcwdb`` | :func:`py2:os.getcwd` | :func:`py3:os.getcwdb` …
587 +------------------------------+-------------------------------------+-----------------------------…
588 | ``getoutput`` | :func:`py2:commands.getoutput` | :func:`py3:subprocess.getout…
589 +------------------------------+-------------------------------------+-----------------------------…
590 | ``http_cookiejar`` | :mod:`py2:cookielib` | :mod:`py3:http.cookiejar` …
591 +------------------------------+-------------------------------------+-----------------------------…
592 | ``http_cookies`` | :mod:`py2:Cookie` | :mod:`py3:http.cookies` …
593 +------------------------------+-------------------------------------+-----------------------------…
594 | ``html_entities`` | :mod:`py2:htmlentitydefs` | :mod:`py3:html.entities` …
595 +------------------------------+-------------------------------------+-----------------------------…
596 | ``html_parser`` | :mod:`py2:HTMLParser` | :mod:`py3:html.parser` …
597 +------------------------------+-------------------------------------+-----------------------------…
598 | ``http_client`` | :mod:`py2:httplib` | :mod:`py3:http.client` …
599 +------------------------------+-------------------------------------+-----------------------------…
600 | ``BaseHTTPServer`` | :mod:`py2:BaseHTTPServer` | :mod:`py3:http.server` …
601 +------------------------------+-------------------------------------+-----------------------------…
602 | ``CGIHTTPServer`` | :mod:`py2:CGIHTTPServer` | :mod:`py3:http.server` …
603 +------------------------------+-------------------------------------+-----------------------------…
604 | ``SimpleHTTPServer`` | :mod:`py2:SimpleHTTPServer` | :mod:`py3:http.server` …
605 +------------------------------+-------------------------------------+-----------------------------…
606 | ``input`` | :func:`py2:raw_input` | :func:`py3:input` …
607 +------------------------------+-------------------------------------+-----------------------------…
608 | ``intern`` | :func:`py2:intern` | :func:`py3:sys.intern` …
609 +------------------------------+-------------------------------------+-----------------------------…
610 | ``map`` | :func:`py2:itertools.imap` | :func:`py3:map` …
611 +------------------------------+-------------------------------------+-----------------------------…
612 | ``queue`` | :mod:`py2:Queue` | :mod:`py3:queue` …
613 +------------------------------+-------------------------------------+-----------------------------…
614 | ``range`` | :func:`py2:xrange` | :func:`py3:range` …
615 +------------------------------+-------------------------------------+-----------------------------…
616 | ``reduce`` | :func:`py2:reduce` | :func:`py3:functools.reduce`…
617 +------------------------------+-------------------------------------+-----------------------------…
618 | ``reload_module`` | :func:`py2:reload` | :func:`py3:imp.reload`, …
619 | | | :func:`py3:importlib.reload`…
621 +------------------------------+-------------------------------------+-----------------------------…
622 | ``reprlib`` | :mod:`py2:repr` | :mod:`py3:reprlib` …
623 +------------------------------+-------------------------------------+-----------------------------…
624 | ``shlex_quote`` | :mod:`py2:pipes.quote` | :mod:`py3:shlex.quote` …
625 +------------------------------+-------------------------------------+-----------------------------…
626 | ``socketserver`` | :mod:`py2:SocketServer` | :mod:`py3:socketserver` …
627 +------------------------------+-------------------------------------+-----------------------------…
628 | ``_thread`` | :mod:`py2:thread` | :mod:`py3:_thread` …
629 +------------------------------+-------------------------------------+-----------------------------…
630 | ``tkinter`` | :mod:`py2:Tkinter` | :mod:`py3:tkinter` …
631 +------------------------------+-------------------------------------+-----------------------------…
632 | ``tkinter_dialog`` | :mod:`py2:Dialog` | :mod:`py3:tkinter.dialog` …
633 +------------------------------+-------------------------------------+-----------------------------…
634 | ``tkinter_filedialog`` | :mod:`py2:FileDialog` | :mod:`py3:tkinter.FileDialog…
635 +------------------------------+-------------------------------------+-----------------------------…
636 | ``tkinter_scrolledtext`` | :mod:`py2:ScrolledText` | :mod:`py3:tkinter.scrolledte…
637 +------------------------------+-------------------------------------+-----------------------------…
638 | ``tkinter_simpledialog`` | :mod:`py2:SimpleDialog` | :mod:`py3:tkinter.simpledial…
639 +------------------------------+-------------------------------------+-----------------------------…
640 | ``tkinter_ttk`` | :mod:`py2:ttk` | :mod:`py3:tkinter.ttk` …
641 +------------------------------+-------------------------------------+-----------------------------…
642 | ``tkinter_tix`` | :mod:`py2:Tix` | :mod:`py3:tkinter.tix` …
643 +------------------------------+-------------------------------------+-----------------------------…
644 | ``tkinter_constants`` | :mod:`py2:Tkconstants` | :mod:`py3:tkinter.constants`…
645 +------------------------------+-------------------------------------+-----------------------------…
646 | ``tkinter_dnd`` | :mod:`py2:Tkdnd` | :mod:`py3:tkinter.dnd` …
647 +------------------------------+-------------------------------------+-----------------------------…
648 | ``tkinter_colorchooser`` | :mod:`py2:tkColorChooser` | :mod:`py3:tkinter.colorchoos…
649 +------------------------------+-------------------------------------+-----------------------------…
650 | ``tkinter_commondialog`` | :mod:`py2:tkCommonDialog` | :mod:`py3:tkinter.commondial…
651 +------------------------------+-------------------------------------+-----------------------------…
652 | ``tkinter_tkfiledialog`` | :mod:`py2:tkFileDialog` | :mod:`py3:tkinter.filedialog…
653 +------------------------------+-------------------------------------+-----------------------------…
654 | ``tkinter_font`` | :mod:`py2:tkFont` | :mod:`py3:tkinter.font` …
655 +------------------------------+-------------------------------------+-----------------------------…
656 | ``tkinter_messagebox`` | :mod:`py2:tkMessageBox` | :mod:`py3:tkinter.messagebox…
657 +------------------------------+-------------------------------------+-----------------------------…
658 | ``tkinter_tksimpledialog`` | :mod:`py2:tkSimpleDialog` | :mod:`py3:tkinter.simpledial…
659 +------------------------------+-------------------------------------+-----------------------------…
660 | ``urllib.parse`` | See :mod:`six.moves.urllib.parse` | :mod:`py3:urllib.parse` …
661 +------------------------------+-------------------------------------+-----------------------------…
662 | ``urllib.error`` | See :mod:`six.moves.urllib.error` | :mod:`py3:urllib.error` …
663 +------------------------------+-------------------------------------+-----------------------------…
664 | ``urllib.request`` | See :mod:`six.moves.urllib.request` | :mod:`py3:urllib.request` …
665 +------------------------------+-------------------------------------+-----------------------------…
666 | ``urllib.response`` | See :mod:`six.moves.urllib.response`| :mod:`py3:urllib.response` …
667 +------------------------------+-------------------------------------+-----------------------------…
668 | ``urllib.robotparser`` | :mod:`py2:robotparser` | :mod:`py3:urllib.robotparser…
669 +------------------------------+-------------------------------------+-----------------------------…
670 | ``urllib_robotparser`` | :mod:`py2:robotparser` | :mod:`py3:urllib.robotparser…
671 +------------------------------+-------------------------------------+-----------------------------…
672 | ``UserDict`` | :class:`py2:UserDict.UserDict` | :class:`py3:collections.User…
673 +------------------------------+-------------------------------------+-----------------------------…
674 | ``UserList`` | :class:`py2:UserList.UserList` | :class:`py3:collections.User…
675 +------------------------------+-------------------------------------+-----------------------------…
676 | ``UserString`` | :class:`py2:UserString.UserString` | :class:`py3:collections.User…
677 +------------------------------+-------------------------------------+-----------------------------…
678 | ``winreg`` | :mod:`py2:_winreg` | :mod:`py3:winreg` …
679 +------------------------------+-------------------------------------+-----------------------------…
680 | ``xmlrpc_client`` | :mod:`py2:xmlrpclib` | :mod:`py3:xmlrpc.client` …
681 +------------------------------+-------------------------------------+-----------------------------…
682 | ``xmlrpc_server`` | :mod:`py2:SimpleXMLRPCServer` | :mod:`py3:xmlrpc.server` …
683 +------------------------------+-------------------------------------+-----------------------------…
684 | ``xrange`` | :func:`py2:xrange` | :func:`py3:range` …
685 +------------------------------+-------------------------------------+-----------------------------…
686 | ``zip`` | :func:`py2:itertools.izip` | :func:`py3:zip` …
687 +------------------------------+-------------------------------------+-----------------------------…
688 | ``zip_longest`` | :func:`py2:itertools.izip_longest` | :func:`py3:itertools.zip_lon…
689 +------------------------------+-------------------------------------+-----------------------------…
694 .. module:: six.moves.urllib.parse
695 …:synopsis: Stuff from :mod:`py2:urlparse` and :mod:`py2:urllib` in Python 2 and :mod:`py3:urllib.p…
697 Contains functions from Python 3's :mod:`py3:urllib.parse` and Python 2's:
725 * :func:`py2:urllib.unquote` (also exposed as :func:`py3:urllib.parse.unquote_to_bytes`)
733 .. module:: six.moves.urllib.error
734 …:synopsis: Stuff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 and :mod:`py3:urllib.er…
736 Contains exceptions from Python 3's :mod:`py3:urllib.error` and Python 2's:
751 .. module:: six.moves.urllib.request
752 …:synopsis: Stuff from :mod:`py2:urllib` and :mod:`py2:urllib2` in Python 2 and :mod:`py3:urllib.re…
754 Contains items from Python 3's :mod:`py3:urllib.request` and Python 2's:
801 .. module:: six.moves.urllib.response
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:
814 Advanced - Customizing renames
817 .. currentmodule:: six
819 It is possible to add additional names to the :mod:`six.moves` namespace.
824 Add *item* to the :mod:`six.moves` mapping. *item* should be a
830 Remove the :mod:`six.moves` mapping called *name*. *name* should be a
840 Create a mapping for :mod:`six.moves` called *name* that references different
847 Create a mapping for :mod:`six.moves` called *name* that references different