News for hackers. Stuff that matters.
Re:Static types in Python by dom96 on Friday October 14, 2016 @07:14AM (#12707324)
> I really feel like in order to get the best of duck typing, you need a good syntax for describing types by usage, not by explicit name.

Not sure if this is of interest to you, but the Nim[1] programming language offers a feature that allows you to do exactly what you described. It is called concepts and is documented here: http://nim-lang.org/docs/manual.html#generics-concepts

As a bonus, Nim is also quite Python-like.

1 - http://nim-lang.org

Re:Static types in Python by clusmore on Friday October 14, 2016 @07:19AM (#12707344)
Yep that sounds like what I mean. Haskell typeclasses, Go interfaces, TypeScript interfaces are further examples. Not Java/C# interfaces though, as they need to be declared at design time, and you can't force existing classes to implement interfaces they haven't already declared themselves as implementing.