ConfigParser и Словарь Integer

на текущий момент читаю словари из файла:

global Size; Size = Cfg.Read(self, 'Size')

class Cfg:
    def Read(self, sections):
        self.cp = ConfigParser()
        self.cp.read(file)
        sections = self.cp[sections]
        return sections

в file:

[Size]
width = 1920
height = 1080
border = 1
icon = 30
indent = 172
backlight = 2

в результате у переменных вместо значения int (0, 1, 2) получается тип str ('1', '2', '3') и приходится каждый элемент отдельно переводить в int...

есть ли возможность используя словари прочитать значения именно int ?

может что-то такое:

out1 = self.cp[sections]
out2 = out1[key, int(out1[key])]
return out2

Ответы (2 шт):

Автор решения: vadim vaduxa

configparser

a_float = config.getfloat('Section1', 'a_float')
an_int = config.getint('Section1', 'an_int')
print(a_float + an_int)
→ Ссылка
Автор решения: biomotor

спасибо, ответ нашел самостоятельно:

out = {}
for name, value in self.cp.items(sections):
    out.update([(name, int(value))])
return out
→ Ссылка