Conventions for iterators

Alex Martelli aleax at aleax.it
Fri Feb 1 12:15:32 EST 2002


Tim Peters wrote:
        ...
>>>> d = {1:1, 2:2}
        ...
> If you can't live with that, good!  Do the sensible thing and iterate over
> a *copy* (for k in d.keys(); for k, v in d.copy(); etc).

Presumably "for k, v in d.items()" -- "for k,v in d.copy()" would work only
if d's keys were all immutable sequences with two items [catching the
_timbot_ in a typo -- dies albo signanda lapillo...!-)].


Alex




More information about the Python-list mailing list