issubclass(C, Mapping) not behaving as expected
- From: anntzer.lee@xxxxxxxxx
- Date: Wed, 30 May 2012 00:55:00 -0700 (PDT)
from collections import *
class C(object):
def __iter__(self): pass
def __contains__(self, i): pass
def __len__(self): pass
def __getitem__(self, i): pass
issubclass(C, Mapping) => False
[issubclass(C, cls) for cls in Mapping.__mro__] => [False, True, True, True, True]
i.e. C does implement Sized, Iterable and Container.
I would have expected that just as issubclass(C, Sized) checks for the presence of a "__len__" method, issubclass(C, Mapping) would check for the presence of the three methods required by each immediate superclass?
Antony
.
- Follow-Ups:
- Re: issubclass(C, Mapping) not behaving as expected
- From: Steven D'Aprano
- Re: issubclass(C, Mapping) not behaving as expected
- Prev by Date: python3 raw strings and \u escapes
- Next by Date: ctypes callback with char array
- Previous by thread: python3 raw strings and \u escapes
- Next by thread: Re: issubclass(C, Mapping) not behaving as expected
- Index(es):