Skip to content

Instantly share code, notes, and snippets.

@spjwebster
Last active December 22, 2015 06:08
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 spjwebster/6428645 to your computer and use it in GitHub Desktop.
Save spjwebster/6428645 to your computer and use it in GitHub Desktop.
import datetime
class Base(object):
pass
class Foo(Base):
name = None
_modified = None
@property
def modified(self):
return self._modified;
@modified.setter
def modified(self, value):
self._modified = value
def __setattr__(self, name, value):
Base.__setattr__(self, name, value)
if name != '_modified':
Base.__setattr__(self, '_modified', datetime.datetime.now())
foo = Foo()
print(foo._modified)
foo.name = "Bar"
print(foo._modified)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment