issubclass(dict, Mapping)

kj no.email at please.post
Wed Dec 22 20:41:08 EST 2010


In <4d127d5e$0$29997$c3e8da3$5496439d at news.astraweb.com> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:

>On Wed, 22 Dec 2010 14:20:51 +0000, kj wrote:

>> Here's another example, fresh from today's crop of wonders:
>> 
>> (v. 2.7.0)
>>>>> from collections import Mapping
>>>>> issubclass(dict, Mapping)
>> True
>>>>> dict.__bases__
>> (<type 'object'>,)
>>>>> [issubclass(b, Mapping) for b in dict.__bases__]
>> [False]
>> 
>> So dict is a subclass of Mapping, even though none of the bases of dict
>> is either Mapping or a subclass of Mapping.  Great.


>Yes. So what?

That's being deliberately obtuse.  The situation described goes
smack against standard OOP semantics, which would be fine if all
this stuff was documented clearly and reasonably, i.e. in one
(preferably "official") place rather than scattered over a bazillion
separate documents, PEP this, module that, GvR musing #42, etc.

Let's just say that I'm looking forward to the end to these surprises.

~kj



More information about the Python-list mailing list