<br><br><div><span class="gmail_quote">On 2/20/06, <b class="gmail_sendername">Raymond Hettinger</b> &lt;<a href="mailto:raymond.hettinger@verizon.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
raymond.hettinger@verizon.net</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;">
<br>An alternative is to have two possible attributes:<br>&nbsp;&nbsp;d.default_factory = list<br>or<br>&nbsp;&nbsp;d.default_value = 0<br>with an exception being raised when both are defined (the test is done when the<br>attribute is created, not when the lookup is performed).
<br><br>
</blockquote></div><br>Why not have the factory function take the key
being looked up as an argument?&nbsp; Seems like there would be uses to
customize the default based on the key.&nbsp; It also forces you to
handle list factory functions and constant factory functions (amongst
others) to be handled the same way:<br>
<br>
d.default_factory = lambda k : list()<br>
d.default_factory = lambda k : 0<br>
<br>
Dan Gass<br>