A ChainMap that allows changing an item in-place.
| 60 | ################ Global Environment |
| 61 | |
| 62 | class Environment(ChainMap[Symbol, Any]): |
| 63 | "A ChainMap that allows changing an item in-place." |
| 64 | |
| 65 | def change(self, key: Symbol, value: Any) -> None: |
| 66 | "Find where key is defined and change the value there." |
| 67 | for map in self.maps: |
| 68 | if key in map: |
| 69 | map[key] = value # type: ignore[index] |
| 70 | return |
| 71 | raise KeyError(key) |
| 72 | |
| 73 | |
| 74 | def standard_env() -> Environment: |
no outgoing calls