I have some code:
report['ipconfig'] = [line.decode('cp866') for line in report['ipconfig']]
Can I make this code more simple?
I don't know if this is more simple (what does that even mean?), but it's a different way of doing it:
report['ipconfig'] = map(lambda x : x.decode('cp866'), report['ipconfig'])
Do you need something more verbose?
lst = list()
for line in report['ipconfig']:
lst.append(line.decode('cp866'))
report['ipconfig'] = lst
You can use codecs module to read initial data. Wrap your reader in codecs.getreader and reencoding becomes not needed.
Seomthing like this ?
for i, line in enumerate(report['ipconfig']):
report['ipconfig'][i] = line.decode('cp866')