On Thu, 16 Dec 2004 12:53:32 -0800, James Stroud wrote: > Then it can be heritable and I can add or override methods. Why aren't > built in lists and dictionaries real heritable types that can save this > kind of patchwork? Is there a pythonic reason I am missing here?
Along with others pointing out that list *is* inheritable and we don't quite know what you mean, I'd point out that any object that inherits the appropriate "magic methods", as described at http://python.org/doc/2.4/ref/sequence-types.html and http://python.org/doc/2.4/ref/sequence-methods.html "is" a list for most things you care about. Want to iterate? Implement __iter__, and "for blah in yourObjType:" will work as you'd want, even for things like trees if you like. Implement __getitem__ and you get [] working right. Python makes matching its "internal protocols" very easy, and you should definately take advantage of that. -- http://mail.python.org/mailman/listinfo/python-list