The below results in RuntimeError: dictionary changed size during iteration
.
class New:
def __init__(self):
self.long_name_a = None
self.long_name_b = None
self.add_value()
def add_value(self):
for att in self.__dict__:
self.att = att
new = New()
assert new.long_name_a == 'long_name_a'
Putting aside option self.long_name_a = 'long_name_a'
or
self.long_name_a = add_value('long_name_a')
, is this possible?