title: Function inside a function best approach?
body: <p>I have the following code below. I would like to execute additional C1 Class methods inside  <code>handleResponseEvent()</code> when the event is fired.  Experimenting I found that if I define <code>handleResponseEvent()</code> inside <code>main()</code> it does what I want. I was wondering if there are other ways of doing the same thing and if defining the event handler function inside <code>main()</code> was the best approach. </p>
  
  <pre><code>def main():
      C1 = DNPClass()
      C1.method1(arg1, arg2, arg3, arg4, arg5)
  
      # subscribing to event
      C1.method2.RequestEvent += handleResponseEvent
      ...
  
  def handleResponseEvent( request, response):
      #code to execute when event handler is called
      #code references additional method from C1 instance
      ....
  </code></pre>