Skip to content

Instantly share code, notes, and snippets.

@mkutsevol
Created December 8, 2016 11:46
Show Gist options
  • Save mkutsevol/23d70ba41e71c1e59e577d65b0878f31 to your computer and use it in GitHub Desktop.
Save mkutsevol/23d70ba41e71c1e59e577d65b0878f31 to your computer and use it in GitHub Desktop.
class descr_cls(object):
def __init__(self):
self.attr_in = 'was here in'
def __setattr__(self, instance, value):
print('set attr {}:{}'.format(instance, value))
self.__dict__[instance] = value
self.__dict__['{}_amended'.format(instance)] = (instance, value)
O = descr_cls()
O.attr1 = 'was here'
print('{}, {}'.format(O.attr1, O.attr_in))
print('{}, {}'.format(O.attr1_amended, O.attr_in_amended))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment