我創建ConfigParser的子類,是容易,我在我的項目中使用:覆蓋ConfigParser get()方法以包含eval的任何缺點?
class MyConfiguration(ConfigParser.ConfigParser):
def __init__(self, filename):
ConfigParser.ConfigParser.__init__(self)
self.readfp(open(filename))
def get(self, section, option):
return eval(ConfigParser.ConfigParser.get(self, section, option))
問:是否有任何缺點(安全性,意想不到的後果)與一個重寫的get()方法包括評估?
我寧願將eval燒入MyConfiguration類,因爲我想在我的配置文件中使用Python數據類型(元組等),但我不想處理遍佈我的項目代碼的evals。
你的意思是,除了eval的所有常見缺點? – delnan 2010-11-14 14:25:07