Paul Boddie wrote: [...] > Regardless of whether myslice inherits from object or not, there's no > persuading the interpreter that it is a genuine slice, and remember > that we can't subclass slice (for some reason unknown). So, it would > appear that the interpreter really wants instances from some specific > set of types (presumably discoverable by looking at list_subscript in > listobject.c) rather than some objects conforming to some interface or > protocol, and perhaps it is implemented this way for performance > reasons. > > In any case, in the core of Python some types/classes are more equal > than others, and for whatever reason the duck typing breaks down - a > case of "malbik endar" [1] that you just have to be aware of, I > suppose. > >>> class mySlice(types.SliceType): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Error when calling the metaclass bases type 'slice' is not an acceptable base type >>>
Indeed. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list