是否有一种简单的方法可以查找类类型中的所有描述符?如果我有这个代码:
class Descriptor(object):
def __init__(self):
self._name = ''
def __get__(self, instance, owner):
print "Getting: %s" % self._name
return self._name
def __set__(self, instance, name):
print "Setting: %s" % name
self._name = name.title()
def __delete__(self, instance):
print "Deleting: %s" %self._name
del self._name
class ContrivedExample(object):
Name = Descriptor()
Date = Descriptor()
我如何从课堂外发现 ContrivedExample.Name 和 ContrivedExample.Date 存在?