python-dbus: Monitoring a remote system bus

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Tue Sep 4 23:57:12 UTC 2018


On Tue, 4 Sep 2018 22:51:29 +0000, Kipper, Matthew wrote:

> It looks like when I invoke MySystemBus(), Connection.__init__
> (https://github.com/posborne/dbus-python/blob/master/dbus/connection.py#L257)
> never runs ...

OK, this looks like a Python question, rather than a dbus question.
Looking at the spec for __new__
<https://docs.python.org/3/reference/datamodel.html#special-method-names>,
I think this line is relevant:

    If __new__() does not return an instance of cls, then the new
    instance’s __init__() method will not be invoked.

Because you are returning an instance of the superclass, not the class
itself. So if you want the superclass __init__ method invoked, you have
to do it yourself.

By the way, while I was able to get most of the Python language into my
head after a few months’ use, that section (“Special Method Names”)
is one I still keep referring back to.


More information about the dbus mailing list