[Steven Bethard] > Sorry, my intent was not to say that I didn't know from the docs that > UserDict.DictMixin required keys(). Clearly it's documented. My > question was *why* does it use keys()? Why use keys() when keys() can > be derived from __iter__, and __iter__ IMHO looks to be a more basic > part of the mapping protocol.
Viewed from the present, __iter__() may seem more basic. However, it is a recent innovation. The keys() method, on the other hand, goes back to the beginning. There were no shortage of mapping-like classes defining keys() but not __iter__(). Still, if __iter__() is provided, UserDict.DictMixin will take advantage of it. The same is also true for __contains__(), and iteritems(). Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list