class A(object):

    def create_b(self):


        class B(object):
            pass
return B()
a = A()
b = a.create_b()
How restrict creation of objects of one class to instances of another in Python?