[Python-ideas] PEP 484 (Type Hints) -- first draft round
Terry Reedy
tjreedy at udel.edu
Sun Jan 18 00:36:26 CET 2015
On 1/16/2015 4:40 PM, Guido van Rossum wrote:
> On Fri, Jan 16, 2015 at 12:34 PM, Dennis Brakhane
> I feel there should be another way to make type annotations and
> "creative" annotations coexist.
>
> The cleanest way to do this would be to use decorators for the
> non-type-hint use case.
I have come to agree with this as the least bad solution. From a
runtime perspective, annotation syntax is merely a nice way to attach to
a function an attribute whose value is a dict whose keys are function
and parameter names. Decorators can do the same (and have been able to
do so since introduced). Repeating (and quoting) names in the decorator
is a nuisance, but as a reader, I would prefer that to having multiple
annotation systems mixed together. The decorator solution, with custom
attribute names, scales better to multiple annotation systems.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list