class Descr(object): def __get__(self, obj, objtype): if obj is None: value = objtype.__dict__['_foo'] print "__get__ (on class): ", value else: value = obj.__dict__['_foo'] print "__get__: ", value return value def __set__(self, obj, value): print "__set__: ", value obj.__dict__['_foo'] = value class Foo(object): _foo = 90 foo = Descr() def __init__(self): self._foo = 123 f = Foo() print f.foo f.foo = 456 print f.foo print "========================" print Foo.foo Foo.foo = 456 print Foo.foo