On 2008-01-18, Aaron Digulla wrote: > Aaron Digulla schrieb: > > Hello, > > > > Please clarify the docs > > (http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#super-and-pyq > >t-classes): > > > > > > Does that mean super() can't / shouldn't / mustn't be used when deriving > > from PyQt classes? What is the fix? > > > > Maybe give an example what won't work and how to fix it or provide a > > link to additional information in the SIP docs or something. > > Anyone? I'm using super() and all the examples in the book "Rapid GUI > Programming with Python and Qt" uses super() when they derive from PyQt > classes, so I'm confused why the reference docs say one shouldn't use > it. Mark, maybe you can shed some light onto this?
super() (at least in Python 2.x) is a bit controversial (see comp.lang.python of old). Nonetheless, GvR has provided it and supports its use, so I use it where I can. You can use super() in a PyQt subclass's initializer (as I do). But you can't use it in other methods because PyQt uses lazy attribute lookup to improve performance, so in a sense the base class methods don't exist until directly accessed (which is why we must use base class calls rather than super()---which is indirect---in other methods). If you prefer a more rigid consistency, you could simply not use super() at all, and always use base class calls (rather like C++). -- Mark Summerfield, Qtrac Ltd., www.qtrac.eu _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt