title: Accessing private variable of one class in another class in python
body: <p>How can I access the private variable 'number' of <code>class B</code> in another <code>class A</code>, in the below code?</p>
  
  <pre class="lang-py prettyprint-override"><code>    class A:
              def write(self):
                  print("hi")
  
              'It should print the private variable number in class B'
              def check(self):
                  print(B.get_number(self))'error occurs here'
  
          class B:
              def __init__(self,num):
                  self.__number = num 
  
              'accessor method'
              def get_number(self):
                  return self.__number
  
          #driver code        
          obj = B(100)
          a = A()
          a.write()
          a.check()
  </code></pre>
  
  <p>The error message I get is <code>'A' object has no attribute '_B__number'</code></p>