[Python-3000] Draft pre-PEP: function annotations
Paul Prescod
paul at prescod.net
Sun Aug 13 09:02:05 CEST 2006
On 8/12/06, Calvin Spealman <ironfroggy at gmail.com> wrote:
>
> I've been looking for a good place to pipe in with the suggestion of
> defining that a dictionary as an annotation is taken as a mapping of
> annotation type names to the annotation itself, such as using {'doc':
> "The single character argument for the command line.", 'type': int} as
> an annotation for some parameter in a function.
I think we need to decide whether metadata type identifiers are just strings
or whether they will typically be objects. I think that the arguments in
favour of objects are strong.
However, reading through all the posts I missed recooperating from a
> long trip I just returned from, I think this coupled with taking _any
> iterable_ (not just list and subtypes) and the whole "your type, your
> annotation" guideline, is definately sufficient for all uses.
>
One reason not to treat any iterable as a list of decorators is that a
string is an iterable. Maybe strings won't be the only annotation that
people want to attach that happens to be iterable for unrelated reasons.
A second reason that I restricted it to lists in particular is to encourage
consistent syntax (rather than one person using a list, another a tuple, a
third a generator, etc.).
And overall it is just overgeneralization. YAGNI. Lists work fine.
def myProtocolChainer(*args):
return list(doSomething(args)):
It is easy to loosen the protocol in future versions if I turn out to be
wrong.
Paul Prescod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060813/a1656667/attachment.html
More information about the Python-3000
mailing list