本文整理汇总了Python中types.FunctionType._update方法的典型用法代码示例。如果您正苦于以下问题:Python FunctionType._update方法的具体用法?Python FunctionType._update怎么用?Python FunctionType._update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.FunctionType
的用法示例。
在下文中一共展示了FunctionType._update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_bindings
# 需要导入模块: from types import FunctionType [as 别名]
# 或者: from types.FunctionType import _update [as 别名]
def setup_bindings(instance, bindings, identifiers, f_globals):
""" Setup the expression bindings for a declarative instance.
Parameters
----------
instance : Declarative
The declarative instance which owns the bindings.
bindings : list
A list of binding dicts created by the enaml compiler.
identifiers : dict
The identifiers scope to associate with the bindings.
f_globals : dict
The globals dict to associate with the bindings.
"""
operators = instance.operators
for binding in bindings:
opname = binding['operator']
try:
operator = operators[opname]
except KeyError:
filename = binding['filename']
lineno = binding['lineno']
block = binding['block']
raise OperatorLookupError(opname, filename, lineno, block)
code = binding['code']
# If the code is a tuple, it represents a delegation
# expression which is a combination of subscription
# and update functions.
if isinstance(code, tuple):
sub_code, upd_code = code
func = FunctionType(sub_code, f_globals)
func._update = FunctionType(upd_code, f_globals)
else:
func = FunctionType(code, f_globals)
operator(instance, binding['name'], func, identifiers)