16 Jul
2020
16 Jul
'20
10:16 a.m.
Hello, On Wed, 15 Jul 2020 23:09:42 -0700 Caleb Donovick <donovick@cs.stanford.edu> wrote:
I have wanted this and suggested it before for use with typing.
Defining protocols is obnoxiously verbose for "struct" like data and keyword arguments to subscript could help alleviate that. I often want to write type hint like this:
``` def foo(x: Protocol[id=int, name=str]): bar(x) baz(x)
Just write them as: --- from __future__ import annotations def foo(x: Protocol(id=int, name=str)): --- So, if using in annotations is the usecase, no new language syntax is required, just update your "Protocol" definition to https://www.python.org/dev/peps/pep-0563/ [] -- Best regards, Paul mailto:pmiscml@gmail.com