All pastes #557237 Raw Edit

gjc

public text v1 · immutable
·published 2007-06-10 22:15 UTC
rendered paste body
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'] = valueclass Foo(object):    _foo = 90    foo = Descr()    def __init__(self):        self._foo = 123f = Foo()print f.foof.foo = 456print f.fooprint "========================"print Foo.fooFoo.foo = 456print Foo.foo