title: printing variable inside a def, inside a class
body: <p>I am new to object oriented programming, what I want to do basically is print a variable inside a def which is in its turn inside a class, I think there's probably a very simple answer but I just can't figure it out, thanks for the assistance, here's my code:</p>
  <pre><code>class test():
      def test2():
          x = 12
  print(test.test2.x)
  </code></pre>
  <p>this gives me the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/vandeventer/x.py&quot;, line 4, in &lt;module&gt;
      print(test.test2.x)
  AttributeError: 'function' object has no attribute 'x'
  </code></pre>
  <p>when I try:</p>
  <pre><code>class test():
      def test2():
          x = 12
  print(test.x)
  </code></pre>
  <p>I get:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/vandeventer/x.py&quot;, line 4, in &lt;module&gt;
      print(test.x)
  AttributeError: type object 'test' has no attribute 'x'
  </code></pre>