Re: [Python-ideas] Discussion: Duck typing with “concepts”

2019-01-22 Thread Marko Ristin-Kaufmann
Hi James, As Ivan has mentioned, Protocols already allow for statical type checks: https://mypy.readthedocs.io/en/latest/protocols.html We didn't need protocols that often at Parquery, maybe half a dozen of times? While we didn't use them in Python, we had to use them intensively in Go where it

Re: [Python-ideas] Discussion: Duck typing with “concepts”

2019-01-22 Thread Ivan Levkivskyi
I think you may be a bit late. Have you heard about PEP 544? -- Ivan On Tue, 22 Jan 2019 at 11:50, James Lu wrote: > So here’s an interesting idea, not a proposal yet. > > In C++20, a Concept is a list of Boolean expressions with a name that can > be used in place of a type in a templated

[Python-ideas] Discussion: Duck typing with “concepts”

2019-01-22 Thread James Lu
So here’s an interesting idea, not a proposal yet. In C++20, a Concept is a list of Boolean expressions with a name that can be used in place of a type in a templated (ie type-generic) function. from typing import Concept Iterator = Concept(lambda o: hasattr(o, "__iter__", lambda o: iter(o) !=