Brano Zarnovican wrote: > But it still doesn't guarantee that __getitem__ accepts keywords. > (What if somebody will extend the Tree class and overlook the > definition of __getitem__ and define a "classic" one)
I deem it more likely that that same somebody will not overlook it and dump your Tree class altogether for not adhering to a sensible convention. Why don't you just introduce a getitem_ex(self, key, all the options you like) method and define __getitem__() in terms of that method? E. g. def getitem_ex(self, key, some_option=None): # ... def __getitem__(self, key): return self.getitem_ex(key, some_option=True) Your docs could then recommend to override getitem_ex() instead of __getitem__() and you and somebody would live happily ever after (*). Peter (*) or at least without calling each other names right from the start. -- http://mail.python.org/mailman/listinfo/python-list