title: Python return values?
body: <p>How do I do this? <em>Can</em> I do this?</p>
  
  <pre><code>def aFunction(argument):  
      def testSomething():  
          if thisValue == 'whatItShouldBe':  
              return True  
          else:  
              return False  
  
      if argument == 'theRightValue': # this is actually a switch using elif's in my code  
          testSomething()  
      else:  
          return False  
  
  def aModuleEntryPoint():  
      if aFunction(theRightValue) == True:  
          doMoreStuff()  
      else:  
          complain()  
  
  aModuleEntryPoint()
  </code></pre>
  
  <p><code>aModuleEntryPoint()</code> needs to first make sure that a condition is true before it starts doing things. Because of encapsulation, <code>aModuleEntryPoint</code> doesn't know how to check the condition, but <code>aFunction()</code> has a sub-function called <code>testSomething()</code> that does know how to check the condition. <code>aModuleEntryPoint()</code> calls <code>aFunction(theRightValue)</code>. </p>
  
  <p>Because <code>theRightValue</code> was passed to <code>aFunction()</code> as an argument, <code>aFunction()</code> calls <code>testSomething()</code>. <code>testSomething()</code> performs the logic test, and either returns <code>True</code> or <code>False</code>. </p>
  
  <p>I need for <code>aModuleEntryPoint()</code> to know what <code>testSomething()</code> decided. I do not want <code>aModuleEntryPoint()</code> to know anything about how <code>testSomething()</code> came to its conclusion.  </p>
  
  <p>It would actually be an accomplishment to post my actual source while removing other functions and what-not, so I had to setup the general gist like this.</p>