for c in innerclasses:
    c = getattr(cls, c)
for a in attributes:
    if not hasattr(c, a):
        setattr(c, a, getattr(cls, a))
return cls
Nested Python class needs to access variable in enclosing class