我创建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