項目に属性があるかどうかをチェックし、それらを呼び出すコードを書き込もうとしていました。私は getattr でそれをやろうとしましたが、変更は永続的ではありません。これを確認するために「ダミー」クラスを作成しました。クラスに使用したコードは次のとおりです。
class X:
def __init__(self):
self.value = 90
def __get(self):
return self.value
def __set(self,value):
self.value = value
value = property(__get,__set)
x = X()
print x.value # this would output 90
getattr(x,"value=",99) # when called from an interactive python interpreter this would output 99
print x.value # this is still 90 ( how could I make this be 99 ? )
ありがとう !