本文整理汇总了Python中types.FunctionType.__qualname__方法的典型用法代码示例。如果您正苦于以下问题:Python FunctionType.__qualname__方法的具体用法?Python FunctionType.__qualname__怎么用?Python FunctionType.__qualname__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.FunctionType
的用法示例。
在下文中一共展示了FunctionType.__qualname__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loads_function
# 需要导入模块: from types import FunctionType [as 别名]
# 或者: from types.FunctionType import __qualname__ [as 别名]
def loads_function(s):
'''Restores a function serialized with :func:`dumps_function`.'''
name, code, globals_, defaults, closure, func_dict, doc, qualname, kwdefaults, annotations = loads(s)
code = marshal.loads(code)
for k, v in globals_.items():
if isinstance(v, Module):
globals_[k] = v.mod
if closure is not None:
import ctypes
ctypes.pythonapi.PyCell_New.restype = ctypes.py_object
ctypes.pythonapi.PyCell_New.argtypes = [ctypes.py_object]
closure = tuple(ctypes.pythonapi.PyCell_New(c) for c in closure)
globals_['__builtins__'] = __builtins__
r = FunctionType(code, globals_, name, defaults, closure)
r.__dict__ = func_dict
r.__doc__ = doc
r.__qualname__ = qualname
r.__kwdefaults__ = kwdefaults
r.__annotations__ = annotations
return r