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

Collin Winter collinw at gmail.com
Sat May 20 03:29:40 CEST 2006


On 5/19/06, Guido van Rossum <guido at python.org> wrote:
> On 5/19/06, Collin Winter <collinw at gmail.com> wrote:
> > 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?"
>
> 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)?

I showed examples like list[str] and tuple[int, int], but I don't
think I included dict[str, int].

On the other hand, my suggestion of dict[key=str, val=int] didn't go
over well either; they liked the readability, but objected to the
extra typing imposed by "key=" and "val=".

> 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.

I'll try asking again after a week or so.

Collin Winter


More information about the Python-3000 mailing list