Re: [Python-3000] PEP 3107 Function Annotations: overloadable ->
"Guido van Rossum" <guido@...> wrote:
> On 1/1/07, Tony Lownds <tony@...> wrote:
> > Is anyone against "->" overloadable as __returns__ /__rreturns__
> > with no semantics for existing types?
> I suggest that you question *really* *hard* whether it's worth it.
> We'd be introducing two very different syntactic uses for '->'. I
> chose this operator to signify function return annotation specifically
> because it *does't* have another meaning in Python. (My first choice
> would've been ':', which is mostly a delimiter that derives its
> meaning from context, like ',', but that would've introduced too much
> syntactic ambiguity.
Just to clarify, the only place '->' is allowable is in the case of
def <name>(<args...>) -> <annotation>:
Given a reading of version 53169 of PEP 3107, I see no reason to even
offer a __returns__ attribute, automatic method call, etc. PEP 3107
already defines the annotation to be specified as a dictionary of named
argument names, with a key of 'return' for the annotation of the return
annotation. Is there any reason why this isn't sufficient?
Even in the context of the signature PEP 362, there is no need for
__returns__, as an annotation-consuming library would check the
signature object for argument annotations, and the func_annotations