title: Nested Function in Python
body: <p>What benefit or implications could we get with Python code like this:</p>
  
  <pre><code>class some_class(parent_class):
      def doOp(self, x, y):
          def add(x, y):
              return x + y
          return add(x, y)
  </code></pre>
  
  <p>I found this in an open-source project, doing something useful inside the nested function, but doing absolutely nothing outside it except calling it. (The actual code can be found <a href="http://bazaar.launchpad.net/~openerp/openobject-server/trunk/annotate/1861/bin/report/render/rml2pdf/trml2pdf.py#L685" rel="noreferrer">here</a>.) Why might someone code it like this? Is there some benefit or side effect for writing the code inside the nested function rather than in the outer, normal function?</p>