News for hackers. Stuff that matters.
Re:Interfaces and Protocols in Python by icegreentea2 on Monday April 26, 2021 @08:24AM (#26941766)
The key would be that 'you sometimes want it'.

The stuff that `zope.interface` gets you is honestly on the... heavy side of what I think makes sense for a lot of scenarios (especially in Python). Which would explain it's relatively low uptake despite having been around for like... 15-20 years??

I haven't used `typing.Protocol` yet (I am mostly still working in 3.7), but it seems to roughly capture the level of 'heaviness' that seems workable.

I do get your gist though. Sometimes I wonder what I'm doing type annotating stuff.

Re:Interfaces and Protocols in Python by psd1 on Tuesday April 27, 2021 @04:54PM (#26961398)
> I do get your gist though. Sometimes I wonder what I'm doing type annotating stuff.

I have to say, I despise trying to decipher untyped functions. This arg is called "order" - do you want an instance of Order, an order ID, or a function for sorting?

Fine, I'll read the docstring. Instead of using the IDE.

Re:Interfaces and Protocols in Python by BerislavLopac on Monday April 26, 2021 @04:48PM (#26947914)
> I haven't used `typing.Protocol` yet (I am mostly still working in 3.7)

You can use it if you install the typing-extensions package: https://pypi.org/project/typing-extensions/