[Python-Dev] Proposal: defaultdict

Alex Martelli aleaxit at gmail.com
Mon Feb 20 22:24:24 CET 2006


On Feb 20, 2006, at 12:38 PM, Aahz wrote:
 ...
>> Can you say, for the record (since nobody else seems to care), if
>> d.getorset(key, func) would work in your use cases?
>> Because I haven't been reading this thread all that closely, you'll 
> have
> to remind me what this means.

Roughly the same (save for method/function difference) as:
def getorset(d, key, func):
 if key not in d: d[key] = func()
 return d[key]
Alex


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /