本文整理汇总了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)