title: Is it a good practice to nest classes?
body: <p>I managed to define a <code>class A</code>, use a list of instances of another <code>class B</code> as <code>class A</code>'s instance variable. <code>class B</code> has a function to change <code>class A</code>'s other instance variable <code>a1</code>. <code>class A</code> also has a function to change <code>class B</code>'s instance variable <code>bb</code>. So <code>class A</code> can access <code>class B</code> and <code>class B</code> can access <code>class A</code>.</p>
  <p>The two classes are nested together. I know we can make things easier to change all instance variables and functions of <code>class B</code> to <code>class A</code>. But in my project, this nested structure is the real way things are.</p>
  <pre><code>class A:
    class B:
        count = 0
        def __init__(self,b1=None,b2=None):
            self.b1 = b1
            self.b2 = b2
        def funcb(self,bb):
            A.a1 = pyfunc1(bb)
    def __init__(self,a1,a2):
        self.a1 = a1
        self.a2 = a2
        self.listb = [A.B()]
    def funca(self,aa):
        A.B.count += 1
        b = A.B(self.a1,self.a2)
        listb.append(b)
        listb[A.B.count].b1 = listb[A.B.count-1].b1.pyfunc2(aa)
        listb[A.B.count].b2 = pyfunc3(aa,self.a2)
        listb[A.B.count].funcb(self.a2)
  </code></pre>
  <p>What I want to know is if such kind of nested class will reduce the python efficiency? Any better solution?</p>