title: How to access "__" (double underscore) variables in methods added to a class
body: <h1>Background</h1>
  
  <p>I wish to use a meta class in order to add helper methods based on the original class. If the method I wish to add uses <code>self.__attributeName</code> I get an <code>AttributeError</code> (because of name mangling) but for an existing identical method this isn't a problem.</p>
  
  <h1>Code example</h1>
  
  <p>Here is a simplified example</p>
  
  <pre><code># Function to be added as a method of Test
  def newfunction2(self):
      """Function identical to newfunction"""
      print self.mouse
      print self._dog
      print self.__cat
  
  class MetaTest(type):
      """Metaclass to process the original class and
      add new methods based on the original class
      """
      def __new__(meta, name, base, dct):
          newclass = super(MetaTest, meta).__new__(
                  meta, name, base, dct
                  )
  
          # Condition for adding newfunction2
          if "newfunction" in dct:
              print "Found newfunction!"
              print "Add newfunction2!"
              setattr(newclass, "newfunction2", newfunction2)
  
          return newclass
  
  # Class to be modified by MetaTest
  class Test(object):
      __metaclass__ = MetaTest
  
      def __init__(self):
          self.__cat = "cat"
          self._dog = "dog"
          self.mouse = "mouse"
  
      def newfunction(self):
          """Function identical to newfunction2"""
          print self.mouse
          print self._dog
          print self.__cat
  
  T = Test()
  T.newfunction()
  T.newfunction2() # AttributeError: 'Test' object has no attribute '__cat'
  </code></pre>
  
  <h1>Question</h1>
  
  <p>Is there a way of adding <code>newfunction2</code> that could use <code>self.__cat</code>?</p>
  
  <p>(Without renaming <code>self.__cat</code> to <code>self._cat</code>.)</p>
  
  <p>And maybe something more fundamental, why isn't <code>self.__cat</code> being treated in the same way for both cases since <code>newfunction2</code> is now part of <code>Test</code>?</p>