A dictionary subclass which returns the key value if it is not in the dict. Parameters ---------- encoder : function or None A function which is applied to a key before adding / retrieving it from the dictionary. If None, the function
(self, encoder=None)
| 477 | |
| 478 | class Dict(dict): |
| 479 | def __init__(self, encoder=None): |
| 480 | """ |
| 481 | A dictionary subclass which returns the key value if it is not in the |
| 482 | dict. |
| 483 | |
| 484 | Parameters |
| 485 | ---------- |
| 486 | encoder : function or None |
| 487 | A function which is applied to a key before adding / retrieving it |
| 488 | from the dictionary. If None, the function defaults to the |
| 489 | identity. Default is None. |
| 490 | """ |
| 491 | super(Dict, self).__init__() |
| 492 | self._encoder = encoder |
| 493 | self._id_max = 0 |
| 494 | |
| 495 | def __setitem__(self, key, value): |
| 496 | if self._encoder is not None: |
nothing calls this directly
no outgoing calls
no test coverage detected