On Dec 18, 8:25 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Dec 18, 2:09 pm, Jonathan Gardner > > > > <[EMAIL PROTECTED]> wrote: > > On Dec 18, 7:08 am, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > We are trying to monkey-patch a third-party library that mixes new and > > > old-style classes with multiple inheritance. In so doing we have > > > uncovered some unexpected behaviour: > > > <snip> > > > > I know this level of messing with python internals is a bit risky but > > > I'm wondering why the above code doesn't work. > > > You've already discovered why--you're mixing old and new style > > classes. > > > Monkey patching is definitely unpythonic. You must be a Ruby guy. Why > > don't you try doing something else to get the behavior you want, > > something more explicit? > > Time and place. > > A well-considered, timely monkey-patch can sometimes save all kinds of > workarounds and other headaches. > > Carl Banks
Indeed, I chuckled at the idea I was a Ruby programmer. Of course it's a bit of a hack but monkey-patching has been common place in the Zope world for years (maybe Zope3 has rid itself of the problem). Agreed, mixing new and old-style classes in multiple inheritance is asking for trouble (although the Guido's essay on the new-style classes suggests you can: http://www.python.org/download/releases/2.2.3/descrintro/#subclassing). I won't name and shame the library involved but unfortunately we can't always pick and choose the tools we work with unless we want to write (or rewrite) everything ourselves. Cheers, Stephen. -- http://mail.python.org/mailman/listinfo/python-list