On Sun, Jun 23, 2013 at 12:46 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > All is not lost, there are ways to make your classes cooperative. The > trick is to have your classes' __init__ methods ignore keyword arguments > they don't know what to do with. object used to do the same thing, but it > no longer does, so you need to add an extra class just before object to > swallow any args before they read object. > > > class Blocker(object): > def __init__(self, **kwargs): > # Block kwargs from reaching object > super(Blocker, self).__init__()
I don't like the idea of doing this with a cooperative __init__ method. If any keyword arguments were passed that weren't consumed, that is probably a bug, and this just swallows the exception instead of reporting it. Of course, if you're doing cooperative inheritance with some other method that doesn't exist on object, then this technique is necessary to prevent the topmost class from trying to call that method on object and erroring out. -- http://mail.python.org/mailman/listinfo/python-list