[Python-3000] Draft pre-PEP: function annotations
Paul Prescod
paul at prescod.net
Sun Aug 13 08:47:29 CEST 2006
On 8/11/06, Collin Winter <collinw at gmail.com> wrote:
>
> >>> def chain(*decorators):
> >>> assert len(decorators) >= 2
> >>>
> >>> def decorate(function):
> >>> sig = function.__signature__
> >>> original = sig.annotations
> >>>
> >>> for i, dec in enumerate(decorators):
> >>> fake = dict((p, original[p][i]) for p in original)
> >>>
> >>> function.__signature__.annotations = fake
> >>> function = dec(function)
> >>>
> >>> function.__signature__.annotations = original
> >>> return function
> >>> return decorate
I must be confused. This is a function returning a function. Does that mean
that the thing showing up in the __signatures__ dictionary is a function? Or
does the caller need to use two sets of parentheses to call the factory
function and then the inner function?
Paul Prescod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060812/3263fd44/attachment.htm
More information about the Python-3000
mailing list