[Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)

Guido van Rossum guido at python.org
Fri May 19 23:38:02 CEST 2006


On 5/19/06, Collin Winter <collinw at gmail.com> wrote:
> On 5/19/06, Guido van Rossum <guido at python.org> wrote:
> > On 5/18/06, Collin Winter <collinw at gmail.com> wrote:
> > > Use of positional arguments to parameterize dict, e.g., dict[str,
> > > Number], is ugly, but keyword arguments would allow the prettier
> > > dict[key=str, value=Number] (which might also be another use case for
> > > the proposed keyword-only arguments).
> >
> > Maybe you didn't find all blog posts, or maybe I really didn't mention
> > it, but I personally prefer dict[str, Number]. There really can't be
> > much confusion over what these mean for anyone who knows what a dict
> > is.
>
> As a quick data point, I showed around your "dict[str, str|int]"
> example to some friends, all of whom have done a decent amount of
> coding in Python. I gave them some background, including that this was
> an example of type parameterization. To quote one fellow, a PhD
> student in CS at Edinburgh: "So, uh, 'dict[str, int|str]' is supposed
> to represent... uh... I give in, what the hell is that supposed to
> denote?"
>
> I know the plural of "anecdote" isn't "data"; maybe c.l.p should be
> polled on some of these things?

Did you first show them list[int] (to get them used to the idea of
parameterized types) and then dict[str, int] (since the int|str union
could be a distractor)?

IMO it's more important whether they are able to recall what it's
supposed to mean after you've explained it once or shown them an
example, than that they be able to guess what it means without
introduction.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list