[Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)

Collin Winter collinw at gmail.com
Tue Aug 15 00:51:40 CEST 2006


On 8/14/06, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 8/14/06, Collin Winter <collinw at gmail.com> wrote:
> > The problem with using lists is that its impossible for non-decorator
> > annotation consumers to know which element "belongs" to them.
>
> The ones whose type they own -- which is why I see at least some
> parallel to exceptions, and its inheritance based semantics.
>
>     def f(a:[mytype("asdfljasdf"),
>              zope.mypackage.something(b,d,e),
>              "a string",
>              mytype([47]),
>              15):
>
> Whoever defined mytype controls the meaning of the mytype annotations;
> anyone not familiar with that package should ignore them (and hope
> there were no side effects in the expressions that generated them).
>
> zope.mypackage controls that annotation; anyone not familiar with that
> product should ignore it (and hope there were no side effects ...)

As hideous as I think this is from an aesthetics/visual noise
standpoint, it's probably the only reliable way to let both decorator-
and non-decorator-based consumers work.

What would the rule be about top-level types? Would you have to use a
list, or could a set or dict be used?

Collin Winter


More information about the Python-3000 mailing list