Package horizons :: Package util :: Package python :: Module defaultweakkeydictionary
[hide private]
[frames] | no frames]

Module defaultweakkeydictionary

source code

DefaultWeakKeyDictionary - Works as a regular WeakKeyDictionary but supports default values. Note: Default feature works slightly different than collections.defaultdict

Usage:

>>> d = DefaultWeakKeyDictionary(lambda key: key*2)
>>> d['foo'] = 4
>>> print d['foo']
4
>>> print d['bar']
'barbar'
Classes [hide private]
  DefaultWeakKeyDictionary
WeakKeyDictionary with specified default value.
Variables [hide private]
  __package__ = 'horizons.util.python'