<br><br><div><span class="gmail_quote">On 8/11/06, <b class="gmail_sendername">Collin Winter</b> &lt;<a href="mailto:collinw@gmail.com">collinw@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt;&gt;&gt; def chain(*decorators):<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; assert len(decorators) &gt;= 2<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; def decorate(function):<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sig = function.__signature__<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; original = 
sig.annotations<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i, dec in enumerate(decorators):<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fake = dict((p, original[p][i]) for p in original)<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function.__signature__.annotations = fake
<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function = dec(function)<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function.__signature__.annotations = original<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return function<br>&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; return decorate</blockquote>
<div><br>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?
<br><br>&nbsp;Paul Prescod<br><br></div></div><br>