def matryoshka(cls):


    class classtypes:
        pass
classtypes = type, type(classtypes)
directory = [n for n in dir(cls) if not n.startswith('_')]
attributes = [n for n in directory if not callable(getattr(cls, n))]
innerclasses = [n for n in directory if isinstance(getattr(cls, n), classtypes)
    ]
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
Вложенный класс Python должен получить доступ к переменной во включающем классе