I'm trying to call functions within a tuple displayed as view(), add(), delete, and exit_program. However, whenever I run the code, the console returns:
TypeError: view() missing 1 required positional argument: 'self'
I also tried to include self or Menu in front of the functions, but to no avail. Is there anyway to fix this?
Here's the code:
from collections import namedtuple
class Menu(object):
def view(self):
pass
def add(self):
pass
def delete(self):
pass
def exit_program(self):
exit()
Option = namedtuple("Option", "label", "function")
_separator = "=" * 25
_options = {1: Option('View goals', view()), 2: Option('Add new goal', add()),
3: Option('Delete existing goal', delete()), 4: Option('Exit program', exit_program())}