1. Joe Amenta
  2. lib3to2
  3. Issues
Issue #9 wontfix

Consider iter*() for dicts

Anonymous created an issue

Consider using iterkeys, itervalues and iteritems for backporting calls to keys, values and items on dicts.

Comments (3)

  1. Joe Amenta repo owner

    Because lists implement the iterator protocol, proper usage of the iterator object returned by some_dict.keys/values/items in Python 3 is also valid usage of the list object returned by some_dict.keys/values/items in Python 2.

    The only problem I can see with leaving this alone would be code that makes strong assumptions about the types of those objects, assumptions stronger than:

    if type(some_object) == type(dict.keys()):

    I think that this is sufficient considering the amount of work that would have to be done to make sure that the object is indeed a dict and not some other object that happens to have a keys/values/items method. I am open to arguments to the contrary, but for now I am marking this one "wontfix".

  2. Log in to comment