return default
def getboolean(self, section, key, default=False):
val = self.get(section, key, default)
- if val == False or val == "0" or val.lower() == "false":
+ if type(val) is bool:
+ return val
+ elif val == "0" or val.lower() == "false":
return False
else:
return True
self.config.set(section, key, str(value))
if self.writeout: self.write()
+ def delete(self, section, key):
+ if self.config.has_section(section):
+ self.config.remove_option(section, key)
+ if self.writeout: self.write()
+
def write(self):
- with open(self.filename+'.tmp', 'wb') as configfile:
+ with open(self.filename+'.tmp', 'w') as configfile:
self.config.write(configfile)
os.rename(configfile.name, self.filename)