[PyQt] QWidget call other __init__ methods, but why?

Phil Thompson phil at riverbankcomputing.com
Tue Jun 28 18:36:05 BST 2016


On 28 Jun 2016, at 6:20 pm, Barry Scott <barry at barrys-emacs.org> wrote:
> 
>> On 28 Jun 2016, at 18:11, Phil Thompson <phil at riverbankcomputing.com> wrote:
>> 
>> You've missed out calls to super().__init__(**kwds)
> 
> Are you suggesting the python has code in super() to see that I use **kwds
> and call more then one __init__?
> 
> You mean like this?
> 
> class Person(QObject, Age):
>    def __init__( self, name='', **kwds ):
>        print( 'instance of Person.__init__' )
>        print( kwds )
>        super().__init__( **kwds )
> 
>        self.name = name
> 
> It gets this error:
> 
> TypeError: __init__() got an unexpected keyword argument 'age'

...because you've missed out calls to super().__init__(**kwds)

See below.

Phil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: qqq.py
Type: text/x-python-script
Size: 523 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160628/1fad49af/attachment-0001.bin>


More information about the PyQt mailing list