Interfaces and Protocols in Python
glyph.twistedmatrix.com
glyph.twistedmatrix.com
Java has all the strong typing and static checking, all you need is to type a lot more words.
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.
You can use it if you install the typing-extensions package: https://pypi.org/project/typing-extensions/
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.
as for other stuff (web-servers, what not), I don't think python can beat kotlin / typescript / etc
Situations where you don't want the heavy-weight and complex JVM.
Cases where you need to interact with C/C++ code a lot (ML, etc.).
Companies where python is the norm and introducing another language adds a lot of overhead.
Edit: Okay I see the original guy stated Java. It is what it is. The real useful answer is to just use any other typed language, and not use Python.
I personally would be hesitant to adopt something depending on some not-well-known library.
Then on the other side, if sth like interfaces are missing in core Python, and typing.Protocol is not quite the same thing, maybe we should try to extend the core typing for sth like typing.Interface? Or maybe first to typing_extensions.
Or, as I understood it, maybe we just need to fix ABCMeta (for MyPy), and then already have what we want?
I'm also not quite sure I understood: Why do I need this base class zope.interface.Interface at all? Why not just implement IPlugin or whatever like it is mentioned there, but not deriving from Interface, and throw NotImplementedError in methods (tools like PyCharm then recognize this is an abstract method). And all concrete types/classes just explicitly need to derive from this IPlugin class. That's mostly what I anyway do already, and what I also see in other projects code. This approach seems to be fine. What's the problem with it?
Which is to say, not widely.
That was around 15 years ago roughly from memory.
Zope and things build on top of it (Plone CMS e.g.) was fairly popular in the early-mid 2000s and was in my opinion ahead of it's time in many ways. But also overkill for most projects.
[1] https://www.ukuug.org/events/linux2001/papers/html/SRichter/...
I discovered Zope in late 2000 while looking for an open source web application platform. Somehow I heard about Zope and thus learnt Python version 1.5.
Zope seemed to be on the cusp of greatness. The Zope conference in Paris in early 2001 was my first tech user group meeting. (Was anyone else reading this there?)
I stopped with Zope in 2003. Then 7 years later got a strange sense of deja vu at a bank I joined, where its trading platform used a Python object database possibly inspired by Zope's ZODB.
It's even mentioned in the history of python https://docs.python.org/3/license.html
When I had to explain it to clients I joked it suffered from “Martian Technology Syndrome”.
https://github.com/zopefoundation/Zope/network/dependents?de...