2015-03-27 23:07:00 +00:00
|
|
|
class Descriptor:
|
|
|
|
def __get__(self, obj, cls):
|
2015-04-04 21:05:30 +00:00
|
|
|
print('get')
|
2015-03-27 23:07:00 +00:00
|
|
|
print(type(obj) is Main)
|
|
|
|
print(cls is Main)
|
|
|
|
return 'result'
|
|
|
|
|
|
|
|
def __set__(self, obj, val):
|
2015-04-04 21:05:30 +00:00
|
|
|
print('set')
|
2015-03-27 23:07:00 +00:00
|
|
|
print(type(obj) is Main)
|
|
|
|
print(val)
|
|
|
|
|
2015-04-04 21:05:30 +00:00
|
|
|
def __delete__(self, obj):
|
|
|
|
print('delete')
|
|
|
|
print(type(obj) is Main)
|
|
|
|
|
2015-03-27 23:07:00 +00:00
|
|
|
class Main:
|
|
|
|
Forward = Descriptor()
|
|
|
|
|
|
|
|
m = Main()
|
2017-02-14 21:57:56 +00:00
|
|
|
try:
|
|
|
|
m.__class__
|
|
|
|
except AttributeError:
|
|
|
|
print("SKIP")
|
2017-06-10 17:03:01 +00:00
|
|
|
raise SystemExit
|
2017-02-14 21:57:56 +00:00
|
|
|
|
2015-03-27 23:07:00 +00:00
|
|
|
r = m.Forward
|
|
|
|
if 'Descriptor' in repr(r.__class__):
|
|
|
|
print('SKIP')
|
2017-12-11 23:20:11 +00:00
|
|
|
raise SystemExit
|
2015-03-27 23:07:00 +00:00
|
|
|
|
2017-12-11 23:20:11 +00:00
|
|
|
print(r)
|
|
|
|
m.Forward = 'a'
|
|
|
|
del m.Forward
|