
On Thu, 13 Jan 2022, 2:24 pm Dennis Sweeney, <sweeney.dennis650@gmail.com> wrote:
Like others expressed, I don't like the idea of the typing and non-typing parts of Python separating.
Has anyone considered adding a new special method like `__arrow__` or something, that would be user-definable, but also defined for tuples and types as returning a Callable? For example `int -> str` could mean Callable[[int], str], and (int, str) -> bool could mean Callable[[int, str], bool]. I would find that sort of semantics more agreeable since Python already has operators that dispatch to dunder methods, and anyone who knows how that bit of Python works would automatically mostly know how the new operator works.
If such a protocol were to be proposed, then int.__arrow__ could be defined such that "1 -> 100" was equivalent to "range(1, 100)" (in addition to the typing use cases). The existing section on runtime behaviour in the PEP doesn't look ready for SC consideration, since it essentially says "this hasn't been defined yet". Cheers, Nick.