container-indepentent iteration code ?

Jeff Epler jepler at unpythonic.net
Thu Sep 9 15:46:06 CEST 2004


def viter(container):
    """Iterate over values of a container"""
    if hasattr(container, "itervalues"):
        return container.itervalues()
    return iter(container)

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040909/1a1d4a81/attachment.sig>


More information about the Python-list mailing list