super() doesn't actually run through all of your multiple super classes and
call their init methods. It just helps you resolve the proper method in the
tree. In a case where you actually do need to run the init on more than one
class, in a specific order, you would need to do it explicitly as you have
shown. But in your specific example, baseUIClass is simply a UI wrapper
generated from uic, with no init anyways. So its not even needed.

I generally use super() to avoid having to explicitly name the super
classes and just let it figure it out for me.

Nice link on that second article.




On Tue, Nov 13, 2012 at 12:20 PM, Jonas Avrin <[email protected]> wrote:

> It seems like everybody's crazy about super() but is it really necessary
> in most cases?
>
> #Original pseudo-code, from another thread here.
> class Ui_MainWindow(baseUIWidget, baseUIClass):
>     def __init__(self,parent=None):
>         super(Ui_MainWindow, self).__init__(parent)
>
> #Edit: Calls the immediate base class
> class Ui_MainWindow(baseUIWidget, baseUIClass):
>     def __init__(self, *args):
>         baseUIWidget.__init__(self, *args)
>         baseUIClass.__init__(self, *args)
>
> also check this thread out:
> http://bytes.com/topic/python/answers/709706-super-apply-__init__-when-subclassing
> *
> There is some debate about which to use especially in bigger dev
> environments.  Is it better speaking as a python 2.6 developer to
> explicitly subclass or use super().__init__() in alignment with new class
> object implementation?  My tools are sometimes using multiple inheritance.
> Keep in mind I haven't really written anything fully OOP that is widely
> circulated.*
>
> http://rhettinger.wordpress.com/2011/05/26/super-considered-super/
>
> Just thought I'd crowd source some common practices here while I'm reading
> up on the subject.  Thanks!
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to