138 | | ||Cookie||module||maps to http.cookies in Py3|| |
139 | | ||reduce||function|| || |
140 | | ||basestring||type|| || |
141 | | ||unichr||function|| || |
142 | | ||unicodeT||type||for type checking, instead of {{{unicode}}} in Py2, maps to {{{str}}} in Py3|| |
143 | | ||STRING_TYPES||tuple||maps to tuple of all known string types: (str,unicode) in Py2, (str,) in Py3, for type checking|| |
144 | | ||sorted_locale||lambda i||locale-sensitive sorting, {{{sorted(i, cmp=locale.strcoll)}}} in Py2, {{{sorted(i, key=locale.strxfrm)}}} in Py3|| |
145 | | ||long||type||same as {{{int}}} in Py3, so can occasionally lead to redundancy|| |
146 | | ||INTEGER_TYPES||tuple||maps to tuple of all known integer types: (int,long) in Py2, (int,) in Py3, for use with {{{isinstance}}}|| |
147 | | ||!ClassType||type||replaces {{{types.ClassType}}} (old-style classes) in Py2, maps to {{{type}}} in Py3 (old-style classes do no longer exist)|| |
148 | | ||CLASS_TYPES||tuple||maps to tuple of all known class types: {{{(type,types.ClassType)}}} in Py2, just (types,) in Py3, for use with {{{isinstance}}}|| |
149 | | ||xrange||function||maps to {{{range}}} in Py3, since {{{xrange}}} does no longer exist (but {{{range}}} behaves like it)|| |
152 | | ||HTTPError||Exception||replaces urllib2.HTTPError in Py2, '''NB''' HTTPError is a subclass of URLError, so must be caught first in order to differentiate|| |
153 | | ||URLError||Exception||replaces urllib2.URLError in Py2|| |
154 | | ||urlopen||function||replaces urllib.urlopen and urllib2.urlopen in Py2|| |
| 146 | |
| 147 | ==== Functions ==== |
| 148 | |
| 149 | ||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =|| |
| 150 | ||reduce||function|| || |
| 151 | ||sorted_locale||lambda i||locale-sensitive sorting, {{{sorted(i, cmp=locale.strcoll)}}} in Py2, {{{sorted(i, key=locale.strxfrm)}}} in Py3|| |
| 152 | ||unichr||function|| || |
| 155 | ||urlopen||function||replaces urllib.urlopen and urllib2.urlopen in Py2|| |
| 156 | ||xrange||function||maps to {{{range}}} in Py3, since {{{xrange}}} does no longer exist (but {{{range}}} behaves like it)|| |
| 157 | |
| 158 | ==== Types ==== |
| 159 | |
| 160 | ||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =|| |
| 161 | ||basestring||type|| || |
| 162 | ||long||type||same as {{{int}}} in Py3, so can occasionally lead to redundancy|| |
| 163 | ||unicodeT||type||for type checking, instead of {{{unicode}}} in Py2, maps to {{{str}}} in Py3|| |
| 164 | ||!ClassType||type||replaces {{{types.ClassType}}} (old-style classes) in Py2, maps to {{{type}}} in Py3 (old-style classes do no longer exist)|| |
| 165 | |
| 166 | ==== Type Tuples for isinstance() ==== |
| 167 | |
| 168 | ||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =|| |
| 169 | ||CLASS_TYPES||tuple||maps to tuple of all known class types: {{{(type,types.ClassType)}}} in Py2, just (type,) in Py3|| |
| 170 | ||INTEGER_TYPES||tuple||maps to tuple of all known integer types: (int,long) in Py2, (int,) in Py3|| |
| 171 | ||STRING_TYPES||tuple||maps to tuple of all known string types: (str,unicode) in Py2, (str,) in Py3|| |
| 172 | |
| 173 | ==== Other Classes and Exceptions ==== |
| 174 | |
| 175 | ||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =|| |
| 176 | ||HTTPError||Exception||replaces urllib2.HTTPError in Py2, '''NB''' HTTPError is a subclass of URLError, so must be caught first in order to differentiate|| |