....
Traceback (most recent call last):>>assert isinstance(ListyThing()[:], ListyThing) # I expect True!
File "<stdin>", line 1, in <module>
AssertionError
<type 'list'>>>type(ListyThing()[:]) # I expect ListyThing!
I don't find this intuitive. Is this intentional? I believe this could
be avoided if list.__getitem__ used "self.__class__()" to make a new
instance, instead of "list()", but I don't know how that works under
the hood in C.
I believe this happens a lot of other cases too. Actually, I wrote up
some test cases at http://brodierao.com/etc/listslice/ but I haven't
taken a look at it in quite a while. I believe there's some other
funky stuff going on there as well.
Also, this happens with dict too:
....>>class DictyThing(dict): pass
Traceback (most recent call last):>>assert isinstance(DictyThing().copy(), DictyThing) # I expect True!
File "<stdin>", line 1, in <module>
AssertionError
<type 'dict'>>>type(DictyThing().copy()) # I expect DictyThing!
Any thoughts?