-
-
Save anonymous/9e002e08a188d68a7fcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuditTrail(object): | |
_borg_dict = {} | |
def __init__(self, msg=None): | |
self.__dict__ = self._borg_dict | |
if not hasattr(self, '_log'): | |
self._log = [] | |
if msg: | |
self._log.append(msg) | |
def reset(self): | |
self._log = [] | |
def set_log(self, value): | |
AuditTrail(value) | |
def get_log(self): | |
return self._log | |
log = property(get_log, set_log) | |
############ | |
AuditTrail('line 1') | |
<__main__.AuditTrail at 0x23cd210> | |
AuditTrail().log = 'line 2' | |
AuditTrail().log | |
['line 1', 'line 2'] | |
AuditTrail().reset() | |
AuditTrail().log | |
[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment