[Python-Dev] what is a dict_keys and where can I import it from?
Amaury Forgeot d'Arc
amauryfa at gmail.com
Tue Feb 12 12:38:48 CET 2013
More information about the Python-Dev mailing list
Tue Feb 12 12:38:48 CET 2013
- Previous message: [Python-Dev] what is a dict_keys and where can I import it from?
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Previous message: [Python-Dev] what is a dict_keys and where can I import it from?
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list