[Python-Dev] Should issubclass() be more like isinstance()?

Scott David Daniels Scott.Daniels at Acm.Org
Wed Apr 5 22:31:10 CEST 2006


Crutcher Dunnavant wrote:
> On 4/4/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> Crutcher Dunnavant wrote:
>>> B) issubclass() won't work on a list of classs,
>>  > the way isinstance() does.
>>
>> That sounds more reasonable. I can't think of any
>> reason why it shouldn't work.

There is an issue of confusion:

     class CheeseShop(Sketch, ByCleese, ByGraham): pass

You need to be careful that the user understands

     issubclass(SillyWalks, (Sketch, ByCleese, ByGraham))

is not simply testing that SillyWalks has the same ancestors as
CheeseShop, but is True simply because issubclass(SillyWalks, Sketch)
is True.  More a document issue than anything, but to be considered.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-Dev mailing list