是否有可能使属性断言当它(用于调试的目的)改变了吗?Python的断言在属性设置
class MyClass(object):
def set_my_property(self, value):
self.my_property = value
# TODO: mark my_property so that if it gets set again, an assert
# is triggered
c = MyClass()
c.set_my_property(4)
# any of these lines would cause an assertion
c.set_my_property(8)
c.my_property = 123
你能举一个你的意思吗? – 2011-04-24 09:11:06
@jcomeau_ictx:done – 2011-04-24 09:17:59