On Thu, 13 Jan 2022, 2:24 pm Dennis Sweeney, <sweeney.dennis...@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.


>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/ENTIEFGCG7O7APREWRLKAX72DISHXSNT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to