Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created March 5, 2013 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9e002e08a188d68a7fcd to your computer and use it in GitHub Desktop.
Save anonymous/9e002e08a188d68a7fcd to your computer and use it in GitHub Desktop.
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