2013/2/12 Steven D'Aprano <steve at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130212/94dba57a/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4