I'm trying to create a button class that will have a press method, but when the object is created the function that I pass while creating the object is returned immediately. Is it possible to pass functions into objects and store the results to later be called?
class Button:
def __init__(self, function):
self.function = function
def press(self):
return self.function
def func():
print("results")
button1 = Button(func())
#results is printed here
button1.press()
#I want results to be printed here