Message122389
| Author |
holdenweb |
| Recipients |
eric.smith, holdenweb, lukasz.langa, michael.foord |
| Date |
2010年11月25日.17:54:32 |
| SpamBayes Score |
0.00901841 |
| Marked as misclassified |
No |
| Message-id |
<4CEEA2AE.70304@holdenweb.com> |
| In-reply-to |
<1290707290.51.0.623270227124.issue10533@psf.upfronthosting.co.za> |
| Content |
On 11/25/2010 11:48 AM, Eric Smith wrote:
>
> Eric Smith <eric@trueblade.com> added the comment:
>
> How about:
>
> from collections import defaultdict
>
> class defaultdict_value(defaultdict):
> def __init__(self, value):
> defaultdict.__init__(self, lambda : value)
>
> x = defaultdict_value(3)
> print(x[1])
>
> ----------
+1
But I'd call it defaultdict_const().
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon 2011 Atlanta March 9-17 http://us.pycon.org/
See Python Video! http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/ |
|