def write(self): xml = XML() xml.parseDict(self) db_file = open(self.db_filename, 'w') db_file.write(data.toprettyxml()) db_file.close()