[PyQt] Issue with multiple inheritance
Dmitry Shachnev
mitya57 at ubuntu.com
Fri Jan 20 20:43:10 GMT 2017
Hi all,
I am trying to write a class that inherits from two parent classes: one from
Qt and one mine.
The minimal example is:
-----------------------------------
from PyQt5.QtCore import QObject
class AnotherBase:
def __init__(self, foo):
pass
class MyView(QObject, AnotherBase):
def __init__(self, foo):
QObject.__init__(self)
MyView('foo')
-----------------------------------
When I try to run it (with the latest sip and PyQt releases), I get this:
Traceback (most recent call last):
File "./test.py", line 11, in <module>
MyView('foo')
File "./test.py", line 9, in __init__
QObject.__init__(self)
TypeError: __init__() missing 1 required positional argument: 'foo'
Which sounds strange to me. Why should QObject.__init__ take my argument?
This does not happen when I replace QObject with my own another base class.
This also does not happen if I change the order of inheritance: first
AnotherBase, then QObject.
Is it my misunderstanding or a bug somewhere? (I hope for the former.)
--
Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170120/13f47a29/attachment.sig>
More information about the PyQt
mailing list