title: Passing function to class in Python
body: <p>So I'm working on a class structure for a text-based menu. I need to create the menus and set the actions before actually running the code. So to avoid the function being called to early, I have created a class called Run which takes the given function and runs it. My problem is that I don't know how I should handle the arguments for the function. What I have so far, and which doesn't work is:</p>
  
  <pre><code>class Run:
      def __init__(self, func):
          self.func = func
  
      def execute(self):
          print('Running')
          self.func
  
  def foo(*args):
      print(*args)
  
  baz = Run(foo('bar'))
  
  baz.execute()
  </code></pre>
  
  <p>Just to be clear I first want the function to run when I run <code>baz.execute()</code></p>