本文整理匯總了Python中types.GetSetDescriptorType方法的典型用法代碼示例。如果您正苦於以下問題:Python types.GetSetDescriptorType方法的具體用法?Python types.GetSetDescriptorType怎麽用?Python types.GetSetDescriptorType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類types
的用法示例。
在下文中一共展示了types.GetSetDescriptorType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: isgetsetdescriptor
# 需要導入模塊: import types [as 別名]
# 或者: from types import GetSetDescriptorType [as 別名]
def isgetsetdescriptor(object):
"""Return true if the object is a getset descriptor.
getset descriptors are specialized descriptors defined in extension
modules."""
return isinstance(object, types.GetSetDescriptorType)
示例2: _shadowed_dict
# 需要導入模塊: import types [as 別名]
# 或者: from types import GetSetDescriptorType [as 別名]
def _shadowed_dict(klass):
dict_attr = type.__dict__["__dict__"]
for entry in _static_getmro(klass):
try:
class_dict = dict_attr.__get__(entry)["__dict__"]
except KeyError:
pass
else:
if not (type(class_dict) is types.GetSetDescriptorType and
class_dict.__name__ == "__dict__" and
class_dict.__objclass__ is entry):
return class_dict
return _sentinel
示例3: _shadowed_dict_newstyle
# 需要導入模塊: import types [as 別名]
# 或者: from types import GetSetDescriptorType [as 別名]
def _shadowed_dict_newstyle(klass):
dict_attr = type.__dict__['__dict__']
for entry in _static_getmro(klass):
try:
class_dict = dict_attr.__get__(entry)['__dict__']
except KeyError:
pass
else:
if not (type(class_dict) is types.GetSetDescriptorType and # noqa
class_dict.__name__ == '__dict__' and
class_dict.__objclass__ is entry):
return class_dict
return _sentinel
示例4: save_dictproxy
# 需要導入模塊: import types [as 別名]
# 或者: from types import GetSetDescriptorType [as 別名]
def save_dictproxy(pickler, obj):
log.info("Dp: %s" % obj)
attr = obj.get('__dict__')
#pickler.save_reduce(_create_dictproxy, (attr,'nested'), obj=obj)
if type(attr) == GetSetDescriptorType and attr.__name__ == "__dict__" \
and getattr(attr.__objclass__, "__dict__", None) == obj:
pickler.save_reduce(getattr, (attr.__objclass__,"__dict__"),obj=obj)
return
# all bad below... so throw ReferenceError or TypeError
from weakref import ReferenceError
raise ReferenceError("%s does not reference a class __dict__" % obj)