[Python-ideas] defaultdict factory argument

Terry Reedy tjreedy at udel.edu
Sun Jan 18 06:46:06 CET 2009


Continuing the OP's top posting style..

if not hasattr(d,key):
   d[key] = <long computation>
return d[key]

or variations, including try:...except:.. work for that

Zac Burns wrote:
> For one, it could be used to cache function calls.

>> While I don't disagree in principle, giving an example use-case would
>> probably help.




More information about the Python-ideas mailing list