[Python-3000] Should all iter(keys|items|values) be renamed? (original) (raw)

skip at pobox.com skip at pobox.com
Tue Sep 4 19:27:17 CEST 2007


After Nick's last message I went searching for "iteritems" in the docs. I fixed a couple places (not yet checked in), but eventually came across Mailbox.iteritems. Looking at the mailbox.py code, sure enough, it still exists:

def iteritems(self):
    """Return an iterator over (key, message) tuples."""
    for key in self.keys():
        try:
            value = self[key]
        except KeyError:
            continue
        yield (key, value)

def items(self):
    """Return a list of (key, message) tuples. Memory intensive."""
    return list(self.iteritems())

Should it be renamed items and the second def'n deleted? Same for iterkeys, itervalues where they appear?

Skip



More information about the Python-3000 mailing list