MCPcopy
hub / github.com/fluentpython/example-code-2e / Environment

Class Environment

18-with-match/lispy/py3.9/lis.py:62–71  ·  view source on GitHub ↗

A ChainMap that allows changing an item in-place.

Source from the content-addressed store, hash-verified

60################ Global Environment
61
62class 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
74def standard_env() -> Environment:

Callers 6

test_evaluate_variableFunction · 0.90
standard_envFunction · 0.70
replFunction · 0.70
__call__Method · 0.70
runFunction · 0.70
__call__Method · 0.50

Calls

no outgoing calls

Tested by 1

test_evaluate_variableFunction · 0.72