Changes between Version 52 and Version 53 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
07/05/19 22:57:25 (6 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v52 v53  
    132132The following objects are provided by s3compat:
    133133
     134==== Constants ====
     135
    134136||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =||
    135137||PY2||boolean||Constant indicating whether we're currently running on Py2, should only be used if alternatives cannot be generalized||
    136 ||StringIO||class|| ||
     138
     139==== Modules ====
     140
     141||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =||
     142||Cookie||module||maps to http.cookies in Py3||
    137143||pickle||module||replaces cPickle in Py2||
    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)||
    150144||urlparse||module||maps to urllib.parse in Py3||
    151145||urllib2||module||maps to urllib.requests in Py3, which contains only part of Py2's urllib2 - some urllib2 objects therefore need to be imported separately (see below)||
    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|| ||
    155153||urlencode||function||replaces urllib.urlencode in Py2||
    156154||urllib_quote||function||replaces urllib.quote in Py2||
     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||
    157177||HTMLParser||class||replaces HTMLParser.HTMLParser in Py2||
     178||StringIO||class|| ||
     179||URLError||Exception||replaces urllib2.URLError in Py2||
    158180=== No dict.iteritems, iterkeys or itervalues ===
    159181