[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484
Guido van Rossum
guido at python.org
Tue Aug 9 11:23:54 EDT 2016
On Mon, Aug 8, 2016 at 11:17 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:
> אלעזר wrote:
>
>> class Starship(tuple):
>> damage: int = 0 captain: str = "Kirk"
>>
>> Is an obvious syntax for
>> Starship = NamedTuple('Starship', [('damage', int), ('captain', str)])
>>
>
> But the untyped version of that already has a meaning --
> it's a tuple subclass with two extra class attributes
> that are unrelated to its indexable items.
>
> I thought that type annotations weren't meant to change
> runtime semantics?
Correct, but we can invent a new base class that has these semantics. It's
no different from Enum.
Anyway, I think this will have to be an add-on to be designed after the
basics are done.
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160809/6cae6983/attachment.html>
More information about the Python-ideas
mailing list