You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
532 B
28 lines
532 B
class Descriptor:
|
|
def __get__(self, obj, cls):
|
|
print('get')
|
|
print(type(obj) is Main)
|
|
print(cls is Main)
|
|
return 'result'
|
|
|
|
def __set__(self, obj, val):
|
|
print('set')
|
|
print(type(obj) is Main)
|
|
print(val)
|
|
|
|
def __delete__(self, obj):
|
|
print('delete')
|
|
print(type(obj) is Main)
|
|
|
|
class Main:
|
|
Forward = Descriptor()
|
|
|
|
m = Main()
|
|
r = m.Forward
|
|
if 'Descriptor' in repr(r.__class__):
|
|
print('SKIP')
|
|
else:
|
|
print(r)
|
|
m.Forward = 'a'
|
|
del m.Forward
|
|
|
|
|