I'm am trying to create a list of function in Python. Though my code can "see" the function and attempt to execute it, it runs in to an error saying it's missing a positional argument self.
class cpu:
def __init__(self):
pass
def execute(self):
self.instructions[0]()
def add(self):
print("instr add")
def beq(self):
print("instr beq")
instructions = [add, beq]
cpu_ = cpu()
cpu_.execute()
Output:
Traceback (most recent call last):
File "C:\...\src\error.py", line 17, in <module>
cpu_.execute()
File "C:\...\src\error.py", line 6, in execute
self.instructions[0]()
TypeError: add() missing 1 required positional argument: 'self'