[Python-ideas] PEP 484 (Type Hints) -- first draft round

Guido van Rossum guido at python.org
Mon Jan 19 17:28:29 CET 2015


In the current proposal there is no way to teach the type checker such
dynamic constraints on the value. You could subclass int and you could
implement the constraints dynamically in that class, and you could use that
class in an argument spec. (And you could introspect methods at run time
and extract the annotation types.) But the static type checker would only
check that you're passing instances of that class around, it wouldn't
understand the range constraint.

On Mon, Jan 19, 2015 at 6:26 AM, Martin Teichmann <lkb.teichmann at gmail.com>
wrote:

> Hi everybody,
>
> I'm writing something like remote procedure calls, so type hinting would
> be very interesting to me - I could send out the function parameter types
> to the remote side, which could already check the type of the parameters
> before even sending out a request.
>
> I would however be interested in even more detailed information. Like
> the range in which a number should lie - so giving a maximum and a minimum
> value for an int. Would it be possible with a PEP 484 system to add
> information
> like that? For example by inheriting from int?
>
> Greetings
>
> Martin Teichmann
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150119/45446f70/attachment.html>


More information about the Python-ideas mailing list