Last active
December 22, 2015 06:08
-
-
Save spjwebster/6428645 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
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