Changes between Version 10 and Version 11 of DeveloperGuidelines/Py_2_3


Ignore:
Timestamp:
06/26/19 19:19:46 (6 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Py_2_3

    v10 v11  
    9292||basestring||{{{from s3compat import basestring}}}|| ||
    9393||INTEGER_TYPES||{{{from s3compat import INTEGER_TYPES}}}||maps to tuple of all known integer types: (int,long) in Py2, (int,) in Py3), for use with {{{isinstance}}}||
     94
     95=== No dict.iteritems ===
     96
     97Python-3 does not support {{{dict.iteritems()}}}. We use {{{dict.items()}}} instead:
     98
     99{{{#!Python
     100# Deprecated
     101for x, y in d.iteritems():
     102# Accepted
     103for x, y in d.items():
     104}}}
     105
     106NB In Python-2, {{{dict.items()}}} returns a list of tuples, but in Python-3 it returns a dict view object that is sensitive to changes of the dict. If a list is required, or the dict is changed inside the loop, the result of {{{dict.items()}}} must be converted into a list explicitly.