The inspect.getsource call actually parses the source file, looking for the class definition, and returns the first one it finds at the lowest level of indentation with the name it's looking for. In other words, it won't do what you're asking it to do.
Here's a slightly different approach that results in the output you're looking for, and perhaps will do what you need:
import inspect
class Parent(object):
def source1(self):
class A1(object):
def foo(self):
pass
A = A1
print inspect.getsource(A)
def source2(self):
class A2(object):
def bar(self, a, b, c):
pass
A = A2
print inspect.getsource(A)
parent = Parent()
parent.source1()
parent.source2()
The class definitions can still be referenced by the names you want (e.g. "A"), but the actual definition in the source code uses a different name, so getsource can find it.