diff --git a/porting-code-to-python-3-with-2to3.html b/porting-code-to-python-3-with-2to3.html index cbc611e..654cd6f 100644 --- a/porting-code-to-python-3-with-2to3.html +++ b/porting-code-to-python-3-with-2to3.html @@ -8,7 +8,7 @@ h1:before{counter-increment:h1;content:'Appendix A. '} h2:before{counter-increment:h2;content:'A.' counter(h2) '. '} h3:before{counter-increment:h3;content:'A.' counter(h2) '.' counter(h3) '. '} -tr + tr th:first-child{font:medium 'Arial Unicode MS',FreeSerif,OpenSymbol,'DejaVu Sans',sans-serif} +tr + tr th:first-child{font: medium/1.75 'Arial Unicode MS','DejaVu Sans',FreeSerif,OpenSymbol,sans-serif} table{width:100%;border-collapse:collapse} th,td{width:45%;padding:0 0.5em;border:1px solid #bbb} th{text-align:left;vertical-align:baseline} @@ -258,6 +258,18 @@ from urllib.error import HTTPError
  • The FancyURLopener class, which handles HTTP redirects and other status codes, is still available in the new urllib.request module. The urlencode() function has moved to urllib.parse.
  • The Request object is still available in urllib.request, but constants like HTTPError have been moved to urllib.error. +

    Did I mention that 2to3 will rewrite your function calls too? For example, if your Python 2 code imports the urllib module and calls urllib.urlopen() to fetch data, 2to3 will fix both the import statement and the function call. + +
    Notes +Python 2 +Python 3 +
    +
    import urllib
    +print urllib.urlopen('http://diveintopython3.org/').read()
    +
    import urllib.request, urllib.parse, urllib.error
    +print(urllib.request.urlopen('http://diveintopython3.org/').read())
    +
    +

    dbm

    All the various DBM clones are now in a single package, dbm. If you need a specific variant like GNU DBM, you can import the appropriate module within the dbm package.