Behaves like standard dict.get, but uses value in _default attribute if no default parameter specified. >>> dd = DefDict({'a': 10}, 0) >>> dd.get('a'), dd.get('b'), dd.get('b', 11) (10, 0, 11) >>> print dd {'a': 10}
(self, key, *args)
| 196 | return dict.__getitem__(self, key) #may wish to allow dd[key] to insert key in dd with default value |
| 197 | |
| 198 | def get(self, key, *args): |
| 199 | """Behaves like standard dict.get, but uses value in _default attribute |
| 200 | if no default parameter specified. |
| 201 | |
| 202 | >>> dd = DefDict({'a': 10}, 0) |
| 203 | >>> dd.get('a'), dd.get('b'), dd.get('b', 11) |
| 204 | (10, 0, 11) |
| 205 | >>> print dd |
| 206 | {'a': 10} |
| 207 | """ |
| 208 | if not args: args = (self._default,) |
| 209 | return dict.get(self, key, *args) |
| 210 | |
| 211 | def copy(self): |
| 212 | """Return shallow copy of dictionary. |
no outgoing calls
no test coverage detected