[Python-3000] Type parameterization (was: Re: Type annotations: annotating generators)
Guido van Rossum
guido at python.org
Tue May 23 17:20:54 CEST 2006
On 5/23/06, Gareth McCaughan <gmccaughan at synaptics-uk.com> wrote:
> On Saturday 2006-05-20 20:53, Guido van Rossum wrote:
>
> > On 5/20/06, Tony Lownds <tony at printra.net> wrote:
> > > How about just dict[str:int]?
> >
> > A bit too clever, although it happens to work syntactically -- it
> > calls dict.__getitem__(slice(str, int)).
>
> Hmm. Why "too clever"?
Because you're creatin a correspondence between two entirely unrelated
usages of ':' -- the usage in a dict display is unrelated (and totally
different in nature) than the usage in slices.
> The symmetry with the syntax for dict literals
> is nice, and (to me) it's more instantly apparent that the LH type
> is the key and the RH type the value than with dict[str, int].
>
> Now, Function[(int, int, int): float] isn't so good. ... Then again,
> Function(int, int, int): float is pretty nice. What was the compelling
> reason for not allowing bare slice literals, again? :-)
It's ambiguous, e.g. if you put it at the top level of the condition
in an if statement.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list