Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
xrudelis
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
xrudelis
5y ago
It looks to me like the goals with typing.Protocol are for static type checking. Whereas this module is intended both for interfaces (much like ABCs) and implementation re-use (see Rust's "blanket implementations"). These Tra
2.
▲
by
xrudelis
5y ago
I think these are all equally good. The Impl's name should never need to be referred to, so ultimately the choice should be based on what's easiest to read. EDIT: actually, your examples wouldn't work as-is, since it would re
3.
▲
by
xrudelis
5y ago
That's right. The reason for this is that it's a lot of boilerplate if you were to require listing every relevant Impl block as a superclass of your struct. I also, as a bonus, like enforcing a consistent class naming style.
4.
▲
by
xrudelis
5y ago
This is an idea I had while thinking about how flexible Python inheritance is. I decided to turn it into a weekend project, and now it is my first open-source package. I hope someone finds it useful!
5.
▲
Show HN: Rust-Like Traits in Python
(github.com)
50 points
by
xrudelis
5y ago
|
21 comments