On Fri, Aug 14, 2020 at 08:58:36PM -0400, Ricky Teachey wrote:

> One problem is type hint creation has been extended to built-ins in python
> 3.9, so that you do not have to import Dict, List, et al anymore.
> 
> Without kwd args inside [ ], you would not be able to do this:
> 
> Vector = dict[i=float, j=float]

If it were decided that we do want to be able to type hint dicts with 
keys 'i' and 'j', then there is probably no reason that we couldn't add 
that to the dict builtin. But given the existence of TypedDict, I think 
that the typing maintainers don't want this on builtin dict.

In any case, concrete changes to any builtin are a separate proposal. 
Obviously those changes depend on allowing the syntax, but we could 
allow the syntax without changing any builtins.

The use of this proposed syntax for typing is orthogonal for the use of 
it in other contexts. Typing wants to subscript *types*, while other 
uses such as those in PEP 472 want to subscript *instances*.

Of the two, I personally think subscripting instances is more 
interesting :-)


> dict(i=float, j=float)  # this syntax isn't available

Well, it's only not available because it already has a meaning:

    py> dict(i=float, j=float)
    {'i': <class 'float'>, 'j': <class 'float'>}



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

Reply via email to