2013/2/12 Steven D'Aprano <st...@pearwood.info> > An anomaly, which I cannot explain: > > py> issubclass(type(keys), KeysView) > True > py> type(keys) is KeysView > False > py> type(keys).__mro__ > (<class 'dict_keys'>, <class 'object'>) > > > This disturbs my calm, because I expect that if issubclass returns True, > the two classes will either be identical, or the second will be in the MRO > of the first. What have I missed? >
Ah, the magic of ABCs... KeysView overrides __instancecheck__, and can pretend to be any other class. This is precisely set in Lib/collections/abc.py: KeysView.register(dict_keys) -- Amaury Forgeot d'Arc
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com