Why are tuples immutable?
Alex Martelli
aleaxit at yahoo.com
Thu Dec 23 06:17:50 EST 2004
Jeff Shannon <jeff at ccvcorp.com> wrote:
...
> But, you generally don't "retrieve" _keys_ from dicts. You *use* keys
> to retrieve *values* from a dict. The only way to get a dict to give
> you a key is by using the keys() method (or items() method) to give you
> *all* of the keys.
There are a few more cases, such as iterating on the dict (directly or
via iterkeys or iteritems), and also the pop method. This does not
invalidate your thesis that retrieving keys is a rarer use case than
using keys to retrieve values -- I think you're right about that (hard
to prove, but that's how it seems to me, too).
Alex
More information about the Python-list
mailing list