-
Notifications
You must be signed in to change notification settings - Fork 0
/
env_v1.py
22 lines (19 loc) · 876 Bytes
/
env_v1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# The EnvironmentManager class keeps a mapping between each variable (aka symbol)
# in a brewin program and the value of that variable - the value that's passed in can be
# anything you like. In our implementation we pass in a Value object which holds a type
# and a value (e.g., Int, 10).
class EnvironmentManager:
def __init__(self):
self.environment = {}
# Gets the data associated a variable name
def get(self, symbol):
if symbol in self.environment:
return self.environment[symbol]
return None
# Sets the data associated with a variable name
def set(self, symbol, value):
self.environment[symbol] = value
def print(self):
print("\n----\nfinal dictionary:\n")
for key in self.environment.keys():
print("var: " + str(key) + ", value: " + str(self.environment[key].value()))