title: Python - Make class return object if sub object is not defined
body: <p>I'm not sure if Python allows anything like what I'm trying to achieve. Basically I'm trying to assign a default object to a class so that if you reference the class directly, it returns that object, otherwise it accesses the sub objects of the class.</p>
  
  <p>Here's what I'm trying to achieve in code:</p>
  
  <pre><code>&gt;&gt;&gt; class MyClass(object):
  ...     a = 0
  ...     b = 1
  ...     def __new__(cls):
  ...         return 2
  
  &gt;&gt;&gt; obj = MyClass()
  
  &gt;&gt;&gt; # I want it to print 0
  &gt;&gt;&gt; print obj.a
  AttributeError: 'int' object has no attribute 'a'
  
  &gt;&gt;&gt; # I want it to print 1
  &gt;&gt;&gt; print obj.b
  AttributeError: 'int' object has no attribute 'b'
  
  &gt;&gt;&gt; # I want it to print 2
  &gt;&gt;&gt; print obj
  2
  </code></pre>