Create a new TransformDict with the given *transform* function. *init_dict* and *kwargs* are optional initializers, as in the dict constructor.
(self, transform, init_dict=None, **kwargs)
| 31 | __slots__ = ('_transform', '_original', '_data') |
| 32 | |
| 33 | def __init__(self, transform, init_dict=None, **kwargs): |
| 34 | """Create a new TransformDict with the given *transform* function. |
| 35 | *init_dict* and *kwargs* are optional initializers, as in the |
| 36 | dict constructor. |
| 37 | """ |
| 38 | if not callable(transform): |
| 39 | raise TypeError( |
| 40 | f'expected a callable, got {transform.__class__!r}') |
| 41 | self._transform = transform |
| 42 | # transformed => original |
| 43 | self._original = {} |
| 44 | self._data = {} |
| 45 | if init_dict: |
| 46 | self.update(init_dict) |
| 47 | if kwargs: |
| 48 | self.update(kwargs) |
| 49 | |
| 50 | def getitem(self, key): |
| 51 | """D.getitem(key) -> (stored key, value)""" |