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

Barry Scott barry at barrys-emacs.org
Thu Jun 30 12:15:03 BST 2016


> On 28 Jun 2016, at 18:36, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> 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.


Oh! I going to have to reread all the python docs.

I did not see this described, something I’ll take up with python folks.
I’m sure I’m not the first python developer to be surprised by this.

Thanks for taking the time to explaining this.

Barry

> 
> Phil
> 
> <qqq.py>



More information about the PyQt mailing list