I know eval() and exec() should be avoided, but in this situation it seems like the best choice: I’m getting values from checkboxes and textboxes in wxPython and putting them in my config class. Here’s how I’m using eval():
config = wx.Config()
checkBoxes = ['option_1', 'option_2']
for key in checkBoxes:
config.Write(key, str(eval('self.m_checkBox_'+key+'.GetValue()'))
There aren’t any security problems because there isn’t any user-input to eval, and it seems pretty clear to me. Is there a better way to do this?
1 Answer