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

Tony Lownds tony at printra.net
Tue May 23 02:04:00 CEST 2006


On May 22, 2006, at 4:24 PM, Collin Winter wrote:
> The main use case I'm thinking of is parameterizing mapping types. Say
> I wanted a set of Number lists: in Python 2, I'd just convert the
> lists to tuples before adding them to the set. However, in Python 3,
> converting the lists to tuples will cause any annotations like
> set[list[Number]] to reject the candidate set. I'd like to avoid
> having annotations like set[tuple & EveryElementIs(Number)]. Also,
> before anyone proposes it, I don't think "just remove the offending
> annotations" is a viable solution.
>

How about tuple[T] then? tuple[T,] can represent a 1-tuple.

-Tony




More information about the Python-3000 mailing list