[Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations) (original) (raw)
Jim Jewett jimjjewett at gmail.com
Tue Aug 15 00:22:45 CEST 2006
- Previous message: [Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)
- Next message: [Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/14/06, Collin Winter <collinw at gmail.com> wrote:
On 8/14/06, Paul Prescod <paul at prescod.net> 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):
"""Example of long compound annotationsMaybe annotations this size should just be restricted to Signature modification instead of allowing them in the actual declaration? At least by style guides? """
By the defined meaning of list, these are 5 independent annotations.
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 ...)
"a string" and 15 are builtin types -- so their semantics are defined by core python, which says that they are documentation only -- stripping them off or changing them wouldn't break a properly written program.
Here, multipleannotations assumes that the annotation dicts are keyed on consumer.name;
Too many consumers will call themselves "wrapper" or some such. You should key on the actual type object -- in which case you probably want isinstance to support subtypes.
-jJ
- Previous message: [Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)
- Next message: [Python-3000] Conventions for annotation consumers (was: Re: Draft pre-PEP: function annotations)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]