-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathop_var.py
More file actions
27 lines (21 loc) · 845 Bytes
/
op_var.py
File metadata and controls
27 lines (21 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# VARIABLE CLASS
# Stores a single varible for calculations later
from op import *
class op_var(op):
# Init function - Stores data pertaining to the class
def __init__(self, *argv):
super(op_var, self).__init__(*argv)
# Returns the type of this operator
def getType(self):
return "var"
# Calculates the value of this operator given a dictionary of variable values
def calcValue(self, args):
return args[self.getOperand(0)]
# Used to see if 2 AND statements are the same. Ignores operand order
def __eq__(self, other):
if other == None: return False
if other.getType() != "var": return False
return self.getOperand(0) == other.getOperand(0)
# Used to print this class out nicely
def __str__(self):
return "[VAR: {}]".format(self.getOperand(0))