Changes between Version 47 and Version 48 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
07/04/19 20:06:05 (5 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v47 v48  
    132132The following objects are provided by s3compat:
    133133
    134 ||= '''Name''' =||= '''Type''' =||= '''Import''' =||= '''!Comments/Caveats''' =||
    135 ||PY2||boolean||{{{from s3compat import PY2}}}||Constant indicating whether we're currently running on Py2, should only be used if alternatives cannot be generalized||
    136 ||StringIO||class||{{{from s3compat import StringIO}}}|| ||
    137 ||pickle||module||{{{from s3compat import pickle}}}||replaces cPickle in Py2||
    138 ||reduce||function||{{{from s3compat import reduce}}}|| ||
    139 ||basestring||type||{{{from s3compat import basestring}}}|| ||
    140 ||unichr||function||{{{from s3compat import unichr}}}|| ||
    141 ||unicodeT||type||{{{from s3compat import unicodeT}}}||for type checking, instead of {{{unicode}}} in Py2, maps to {{{str}}} in Py3||
    142 ||STRING_TYPES||tuple||{{{from s3compat import STRING_TYPES}}}||maps to tuple of all known string types: (str,unicode) in Py2, (str,) in Py3, for type checking||
    143 ||sorted_locale||lambda||{{{from s3compat import sorted_locale}}}||locale-sensitive sorting, sorted(x, cmp=locale.strcoll) in Py2, sorted(x, key=locale.strxfrm) in Py3||
    144 ||long||type||{{{from s3compat import long}}}||same as {{{int}}} in Py3, so can occasionally lead to redundancy||
    145 ||INTEGER_TYPES||tuple||{{{from s3compat import INTEGER_TYPES}}}||maps to tuple of all known integer types: (int,long) in Py2, (int,) in Py3, for use with {{{isinstance}}}||
    146 ||!ClassType||type||{{{from s3compat import ClassType}}}||replaces {{{types.ClassType}}} (old-style classes) in Py2, maps to {{{type}}} in Py3 (old-style classes do no longer exist)||
    147 ||CLASS_TYPES||tuple||{{{from s3compat import CLASS_TYPES}}}||maps to tuple of all known class types: {{{(type,types.ClassType)}}} in Py2, just (types,) in Py3, for use with {{{isinstance}}}||
    148 ||xrange||function||{{{from s3compat import xrange}}}||maps to {{{range}}} in Py3, since {{{xrange}}} does no longer exist (but {{{range}}} behaves like it)||
    149 ||urlparse||module||{{{from s3compat import urlparse}}}||maps to urllib.parse in Py3||
    150 ||urllib2||module||{{{from s3compat import urllib2}}}||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)||
    151 ||HTTPError||class||{{{from s3compat import HTTPError}}}||replaces urllib2.HTTPError in Py2||
    152 ||urlopen||function||{{{from s3compat import urlopen}}}||replaces urllib.urlopen and urllib2.urlopen in Py2||
    153 ||urlencode||function||{{{from s3compat import urlencode}}}||replaces urllib.urlencode in Py2||
    154 ||HTMLParser||class||{{{from s3compat import HTMLParser}}}||replaces HTMLParser.HTMLParser in Py2||
     134||= '''Name''' =||= '''Type''' =||= '''!Comments/Caveats''' =||
     135||PY2||boolean||Constant indicating whether we're currently running on Py2, should only be used if alternatives cannot be generalized||
     136||StringIO||class|| ||
     137||pickle||module||replaces cPickle in Py2||
     138||reduce||function|| ||
     139||basestring||type|| ||
     140||unichr||function|| ||
     141||unicodeT||type||for type checking, instead of {{{unicode}}} in Py2, maps to {{{str}}} in Py3||
     142||STRING_TYPES||tuple||maps to tuple of all known string types: (str,unicode) in Py2, (str,) in Py3, for type checking||
     143||sorted_locale||lambda||locale-sensitive sorting, {{{sorted(x, cmp=locale.strcoll)}}} in Py2, {{{sorted(x, key=locale.strxfrm)}}} in Py3||
     144||long||type||same as {{{int}}} in Py3, so can occasionally lead to redundancy||
     145||INTEGER_TYPES||tuple||maps to tuple of all known integer types: (int,long) in Py2, (int,) in Py3, for use with {{{isinstance}}}||
     146||!ClassType||type||replaces {{{types.ClassType}}} (old-style classes) in Py2, maps to {{{type}}} in Py3 (old-style classes do no longer exist)||
     147||CLASS_TYPES||tuple||maps to tuple of all known class types: {{{(type,types.ClassType)}}} in Py2, just (types,) in Py3, for use with {{{isinstance}}}||
     148||xrange||function||maps to {{{range}}} in Py3, since {{{xrange}}} does no longer exist (but {{{range}}} behaves like it)||
     149||urlparse||module||maps to urllib.parse in Py3||
     150||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)||
     151||HTTPError||class||replaces urllib2.HTTPError in Py2||
     152||urlopen||function||replaces urllib.urlopen and urllib2.urlopen in Py2||
     153||urlencode||function||replaces urllib.urlencode in Py2||
     154||HTMLParser||class||replaces HTMLParser.HTMLParser in Py2||
    155155=== No dict.iteritems, iterkeys or itervalues ===
    156156