[Twisted-Python] Inheriting DatagramProtocol, which is an old-style class

Maarten ter Huurne maarten at treewalker.org
Fri Feb 7 22:44:04 MST 2020


On Saturday, 8 February 2020 01:50:04 CET Go Luhng wrote:
> I am creating a child class
> `Child(twisted.internet.protocol.DatagramProtocol)` to implement a
> custom UDP multicast protocol.
> 
> I need to add an `__init__()` to `Child`, but as part of that I need
> to call `super()` which is impossible because `DatagramProtocol` is
> old-style.
> 
> How should I proceed?

There is no __init__() in DatagramProtocol or in its superclass 
AbstractDatagramProtocol, so you can just skip the call.

> Also, why are there old-style classes in the latest release of
> Twisted?

I don't know the reason, but it seems to be deliberate, since 
AbstractDatagramProtocol is annotated with @_oldStyle in the source.

Bye,
		Maarten





More information about the Twisted-Python mailing list