title: Why doesn't python closure work in this scenario?
body: <pre><code>class Example:
      text = &quot;Hello World&quot;
  
      def function():
          print(text)
  
  Example.function()  
  </code></pre>
  <p><code>Example.printText()</code> throws this error <code>NameError: name 'text' is not defined</code></p>
  <p>Why doesn't <code>printText()</code> remember the class attribute <code>text</code>?<br />
  Does it have something to do with order python interprets the code?</p>