rwnobrega@lemmy.world to Python · 2 年前Python interfaces: abandon ABC and switch to Protocolslevelup.gitconnected.comexternal-linkmessage-square9linkfedilinkarrow-up114arrow-down13
arrow-up111arrow-down1external-linkPython interfaces: abandon ABC and switch to Protocolslevelup.gitconnected.comrwnobrega@lemmy.world to Python · 2 年前message-square9linkfedilink
minus-squareRiskablelinkfedilinkEnglisharrow-up2·2 年前I wouldn’t say Protocols are more “fragile”… They’re more strict.
minus-squareplistig@feddit.delinkfedilinkEnglisharrow-up1·2 年前The opposite is true. If you have two interfaces that contain methods with the same name, then they have the same typing.Protocol. It is not possible to specify preconditions or contracts, as you would with abc.
I wouldn’t say Protocols are more “fragile”… They’re more strict.
The opposite is true. If you have two interfaces that contain methods with the same name, then they have the same
typing.Protocol. It is not possible to specify preconditions or contracts, as you would with abc.