10 Apr 2012 18:12
Re: [Traits] Is overwriting __init__ 'viral' ?
On Tue, Apr 10, 2012 at 4:59 PM, David Ohlemacher <dohlemacher <at> scisol.com> wrote: > Hi Robert, > > That is interesting, but Python: Essential Ref, 4th ed, p 120: > > "If you dont know whether the base class defines __init__(), it is > always safe to call it without any arguments because there is always > a default implementation that simply does nothing." > > That seems to be incorrect. I tried it and it does fail. It is not in > errata either. That's an extremely confusing and pointless statement. It's wrong, at least as it is currently worded. If none of the super classes define an __init__(), then it is safe to call the super class's __init__() without arguments because it is just object.__init__(), which does indeed take no argument (and woe betide you if you *do* pass it any arguments). But if any of those super classes define an __init__() then you must pass the correct arguments. You always need to know what you are calling. There is nothing that will work in all situations. -- -- Robert Kern Enthought _______________________________________________ Enthought-Dev mailing list Enthought-Dev <at> mail.enthought.com https://mail.enthought.com/mailman/listinfo/enthought-dev
RSS Feed