5. Python 2 vs. 3

5.1. six

Python six

5.2. Lista kompatybilności Python 2 i Python 3

5.3. Unicode i kodowanie znaków

5.4. Biblioteki standardowe w 2 i 3

Name

Python 2 name

Python 3 name

builtins

py2:__builtin__

py3:builtins

configparser

py2:ConfigParser

py3:configparser

copyreg

py2:copy_reg

py3:copyreg

cPickle

py2:cPickle

py3:pickle

cStringIO

py2:cStringIO.StringIO()

py3:io.StringIO

dbm_gnu

py2:gdbm()

py3:dbm.gnu

_dummy_thread

py2:dummy_thread

py3:_dummy_thread

email_mime_multipart

py2:email.MIMEMultipart

py3:email.mime.multipart

email_mime_nonmultipart

py2:email.MIMENonMultipart

py3:email.mime.nonmultipart

email_mime_text

py2:email.MIMEText

py3:email.mime.text

email_mime_base

py2:email.MIMEBase

py3:email.mime.base

filter

py2:itertools.ifilter()

py3:filter()

filterfalse

py2:itertools.ifilterfalse()

py3:itertools.filterfalse()

getcwd

py2:os.getcwdu()

py3:os.getcwd()

getcwdb

py2:os.getcwd()

py3:os.getcwdb()

http_cookiejar

py2:cookielib

py3:http.cookiejar

http_cookies

py2:Cookie

py3:http.cookies

html_entities

py2:htmlentitydefs

py3:html.entities

html_parser

py2:HTMLParser

py3:html.parser

http_client

py2:httplib

py3:http.client

BaseHTTPServer

py2:BaseHTTPServer

py3:http.server

CGIHTTPServer

py2:CGIHTTPServer

py3:http.server

SimpleHTTPServer

py2:SimpleHTTPServer

py3:http.server

input

py2:raw_input()

py3:input()

intern

py2:intern()

py3:sys.intern()

map

py2:itertools.imap()

py3:map()

queue

py2:Queue

py3:queue

range

py2:xrange()

py3:range()

reduce

py2:reduce()

py3:functools.reduce()

reload_module

py2:reload()

py3:imp.reload(), py3:importlib.reload() on Python 3.4+

reprlib

py2:repr

py3:reprlib

shlex_quote

py2:pipes.quote

py3:shlex.quote

socketserver

py2:SocketServer

py3:socketserver

_thread

py2:thread

py3:_thread

tkinter

py2:Tkinter

py3:tkinter

tkinter_dialog

py2:Dialog

py3:tkinter.dialog

tkinter_filedialog

py2:FileDialog

py3:tkinter.FileDialog

tkinter_scrolledtext

py2:ScrolledText

py3:tkinter.scrolledtext

tkinter_simpledialog

py2:SimpleDialog

py3:tkinter.simpledialog

tkinter_ttk

py2:ttk

py3:tkinter.ttk

tkinter_tix

py2:Tix

py3:tkinter.tix

tkinter_constants

py2:Tkconstants

py3:tkinter.constants

tkinter_dnd

py2:Tkdnd

py3:tkinter.dnd

tkinter_colorchooser

py2:tkColorChooser

py3:tkinter.colorchooser

tkinter_commondialog

py2:tkCommonDialog

py3:tkinter.commondialog

tkinter_tkfiledialog

py2:tkFileDialog

py3:tkinter.filedialog

tkinter_font

py2:tkFont

py3:tkinter.font

tkinter_messagebox

py2:tkMessageBox

py3:tkinter.messagebox

tkinter_tksimpledialog

py2:tkSimpleDialog

py3:tkinter.simpledialog

urllib.parse

See six.moves.urllib.parse

py3:urllib.parse

urllib.error

See six.moves.urllib.error

py3:urllib.error

urllib.request

See six.moves.urllib.request

py3:urllib.request

urllib.response

See six.moves.urllib.response

py3:urllib.response

urllib.robotparser

py2:robotparser

py3:urllib.robotparser

urllib_robotparser

py2:robotparser

py3:urllib.robotparser

UserDict

py2:UserDict.UserDict

py3:collections.UserDict

UserList

py2:UserList.UserList

py3:collections.UserList

UserString

py2:UserString.UserString

py3:collections.UserString

winreg

py2:_winreg

py3:winreg

xmlrpc_client

py2:xmlrpclib

py3:xmlrpc.client

xmlrpc_server

py2:SimpleXMLRPCServer

py3:xmlrpc.server

xrange

py2:xrange()

py3:range()

zip

py2:itertools.izip()

py3:zip()

zip_longest

py2:itertools.izip_longest()

py3:itertools.zip_longest()

5.4.1. Httplib w 2 i 3