class myInst:
    iitt = 15
pass


class deco:

    def __init__(self, id, *args, **kws):
        self.__id = id
self.iitt = 25
self.__name__ = 'another name'


@deco
class myInst2:
    iitt = 15
pass
print('MyInst name :', myInst.__name__)
print('MyInst2 name :', myInst2.__name__)
try:
    raise ValueError('iitt: Error!')
except ValueError as err:
    myVar = err.message.split(':')[0]
l = getattr(myInst, myVar)
print(l)
try:
    raise ValueError('iitt: Error!')
except ValueError as err:
    myVar = err.message.split(':')[0]
l = getattr(myInst2, myVar)
print(l)
myInst = myInst2
try:
    raise ValueError('iitt: Error!')
except ValueError as err:
    myVar = err.message.split(':')[0]
l = getattr(myInst, myVar)
print(l)
Хорошая практика Python: вырезание имен переменных в качестве параметров