| Reorganization and renamingStandard library
Python's standard library has been reorganized in Python 3 for consistency and ease of use. All module names now conform to the style of Python code, PEP 8[1] and some modules are merged.
2to3 contains a retainer that can handle all of these, so this chapter is more about whether you need to support the interest of Python 2 and Python 3 without 2to3 conversion.
The six module [2] supports the consolidation of most reorganized standard libraries. You can import a restructured module from Six.moves:
>>> from six.moves import Cstringio
In Python 2 This is equivalent to:
>>> from Cstringio import Stringio
However in Python 3 this would be equivalent to:
>>> from IO import Stringio
This is also easy if you want to not convert and don't want to use the six module at the same time Python 2 and Python 3. You just have to try. Import from one location, catch errors, and then import from another location. It has nothing to do with where you put Python 3, either before or after, and it can work equally well:
>>> try:
... from io import Stringio ...
except Importerror:
... from Cstringio import String Io
This table contains the renaming and reorganization of all the standard libraries except for the Urllib, URLLIB2, and urlparse reorganization of the other tables:
| Python 2-name word |
Python 3-name Word |
Six name |
| anydbm |
Dbm |
|
| Basehttpserver |
Http.server |
Basehttpserver |
| __builtin__ |
Builtins |
Builtins |
| Cgihttpserver |
Http.server |
Cgihttpserver |
| Configparser |
Configparser |
Configparser |
| Copy_reg |
Copyreg |
Copyreg |
| Cpickle |
Pickle |
Cpickle |
| CProfile |
Profile |
|
| Cstringio.stringio |
Io. Stringio |
Cstringio |
| Cookies |
Http.cookies |
Http_cookies |
| Cookielib |
Http.cookiejar |
Http_cookiejar |
| Dbhash |
Dbm.bsd |
|
| Dbm |
dbm.ndbm |
|
| Dumbdb |
Dbm.dumb |
|
| Dialog |
Tkinter.dialog |
Tkinter_dialog |
| Docxmlrpcserver |
Xmlrpc.server |
|
| FileDialog |
Tkinter. FileDialog |
Tkinter_filedialog |
| Fixtk |
Tkinter._fix |
|
| gdbm |
Dbm.gnu |
|
| Htmlentitydefs |
Html.entities |
Html_entities |
| Htmlparser |
Html.parser |
Html_parser |
| Httplib |
Http.client |
Http_client |
| Markupbase |
_markupbase |
|
| Queue |
Queue |
Queue |
| Repr |
Reprlib |
Reprlib |
| Robotparser |
Urllib.robotparser |
Urllib_robotparser |
| Scrolledtext |
Tkinter.scolledtext |
Tkinter_scrolledtext |
| Simpledialog |
Tkinter.simpledialog |
Tkinter_simpledialog |
| Simplehttpserver |
Http.server |
Simplehttpserver |
| Simplexmlrpcserver |
Xmlrpc.server |
|
| Stringio.stringio |
Io. Stringio |
|
| Socketserver |
Socketserver |
Socketserver |
| Test.test_support |
Test.support |
Tkinter |
| Tkinter |
Tkinter |
Tkinter |
| Tix |
Tkinter.tix |
Tkinter_tix |
| Tkconstants |
Tkinter.constants |
Tkinter_constants |
| Tkcolorchooser |
Tkinter.colorchooser |
Tkinter_colorchooser |
| Tkcommondialog |
Tkinter.commondialog |
Tkinter_commondialog |
| Tkdnd |
Tkinter.dnd |
Tkinter_dnd |
| Tkfiledialog |
Tkinter.filedialog |
|