我遇到了这样一个问题:在字典中添加一个带有新键的新条目将还原以前更改的属性的值。你知道吗
import list_territories as territories
class XmlGeneratorApp:
def __init__(self, parent=None):
self.territory_count = 1
def add_territories(self):
self.territory_count += 1
self.new_entry_name = str("territory%d" % self.territory_count)
self.new_entry = territories.Territories
territories.terr_dict[self.new_entry_name] = self.new_entry
def set_product_price_hd_check_2_false(self, territory_number):
self.territory_number = territory_number
territories.terr_dict["territory2"].product_price_hd_checks = False
以下是您的领土列表:
terr_dict = {}
class Territories(object):
def __init__(self,product_price_hd_checks):
self.product_price_hd_checks = product_price_hd_checks
如果我调用set_product_price_hd_check_2_false
将"territory2"
设置为False,然后调用add_territories
,它会将属性terr_dict["territory2"].product_price_hd_checks
的值重置为True。如果我调用add_territories
来创建多个其他实例(territory3、territory4、territory5等),也是一样的。你知道吗
只有在我的字典里添加新词条时才会发生这种情况。你知道吗
我错过什么了吗?在字典中添加新条目会将值重置为init,这是已知的问题吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐