Scientific.DictWithDefault.DictWithDefault

Package Scientific :: Module DictWithDefault :: Class DictWithDefault |
[frames] | no frames]

# Class DictWithDefault

    UserDict.UserDict --+
                        |
                       DictWithDefault

Dictionary with default values

Instances of this class act like standard Python dictionaries, except that they return a *copy* of |default| for a key that has no associated value.

Instance Methods
__delitem__(self, key) |
__getitem__(self, key) Returns: the associated value. |
__init__(self, default) |
Inherited from `UserDict.UserDict`: `__cmp__`, `__contains__`, `__len__`, `__repr__`, `__setitem__`, `clear`, `copy`, `get`, `has_key`, `items`, `iteritems`, `iterkeys`, `itervalues`, `keys`, `pop`, `popitem`, `setdefault`, `update`, `values`

Class Methods
Inherited from `UserDict.UserDict`: `fromkeys`

Method Details

### __delitem__(self, key) (Index deletion operator) |
Overrides: UserDict.UserDict.__delitem__

### __getitem__(self, key) (Indexing operator) |
Parameters: `key` - the key whose associated value is requested Returns: the associated value. If none is defined, the return value is a copy of the default value. Overrides: UserDict.UserDict.__getitem__

### __init__(self, default) (Constructor) |
Parameters: `default` - the default value that is returned for a key that has no associated value Overrides: UserDict.UserDict.__init__