当前位置: 首页>>代码示例>>Python>>正文


Python types.BuiltinFunctionType方法代码示例

本文整理汇总了Python中types.BuiltinFunctionType方法的典型用法代码示例。如果您正苦于以下问题:Python types.BuiltinFunctionType方法的具体用法?Python types.BuiltinFunctionType怎么用?Python types.BuiltinFunctionType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types的用法示例。


在下文中一共展示了types.BuiltinFunctionType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_object

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def import_object(self):
        ret = ClassLevelDocumenter.import_object(self)
        if isinstance(self.object, classmethod) or \
               (isinstance(self.object, MethodType) and
                self.object.im_self is not None):
            self.directivetype = 'classmethod'
            # document class and static members before ordinary ones
            self.member_order = self.member_order - 1
        elif isinstance(self.object, FunctionType) or \
             (isinstance(self.object, BuiltinFunctionType) and
              self.object.__self__ is not None):
            self.directivetype = 'staticmethod'
            # document class and static members before ordinary ones
            self.member_order = self.member_order - 1
        else:
            self.directivetype = 'method'
        return ret 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:19,代码来源:sage_autodoc.py

示例2: get_module_functions

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def get_module_functions(modules):
  """Finds functions that do not have implemented derivatives.

  Args:
    modules: A list of Python modules. Functions contained in these modules
        will be checked for membership in 'implemented', and if not found,
        will be added to an 'unimplemented' set
    implemented: A Python object containing implemented derivatives. A function
        should be checkable for membership using the `fn in implemented` syntax.

  Returns:
    module_fns: A set of functions, builtins or ufuncs in `modules`.
  """
  module_fns = set()
  for module in modules:
    for key in dir(module):
      attr = getattr(module, key)
      if isinstance(
          attr, (types.BuiltinFunctionType, types.FunctionType, numpy.ufunc)):
        module_fns.add(attr)
  return module_fns 
开发者ID:google,项目名称:tangent,代码行数:23,代码来源:grads.py

示例3: short_repr

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def short_repr(obj):
    if isinstance(obj, (type, types.ModuleType, types.BuiltinMethodType,
                        types.BuiltinFunctionType)):
        return obj.__name__
    if isinstance(obj, types.MethodType):
        try:
            if obj.__self__ is not None:
                return obj.__func__.__name__ + ' (bound)'
            else:
                return obj.__func__.__name__
        except AttributeError:
            # Python < 2.6 compatibility
            if obj.im_self is not None:
                return obj.im_func.__name__ + ' (bound)'
            else:
                return obj.im_func.__name__

    if isinstance(obj, types.FrameType):
        return '%s:%s' % (obj.f_code.co_filename, obj.f_lineno)
    if isinstance(obj, (tuple, list, dict, set)):
        return '%d items' % len(obj)
    return repr(obj)[:40] 
开发者ID:Exa-Networks,项目名称:exaddos,代码行数:24,代码来源:objgraph.py

示例4: typeof

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def typeof(self, cdecl):
        """Parse the C type given as a string and return the
        corresponding <ctype> object.
        It can also be used on 'cdata' instance to get its C type.
        """
        if isinstance(cdecl, basestring):
            return self._typeof(cdecl)
        if isinstance(cdecl, self.CData):
            return self._backend.typeof(cdecl)
        if isinstance(cdecl, types.BuiltinFunctionType):
            res = _builtin_function_type(cdecl)
            if res is not None:
                return res
        if (isinstance(cdecl, types.FunctionType)
                and hasattr(cdecl, '_cffi_base_type')):
            with self._lock:
                return self._get_cached_btype(cdecl._cffi_base_type)
        raise TypeError(type(cdecl)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:20,代码来源:api.py

示例5: smart_decorator

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def smart_decorator(f, create_decorator):
    if isinstance(f, types.FunctionType):
        return wraps(f)(create_decorator(f, True))

    elif isinstance(f, (classtype, type, types.BuiltinFunctionType)):
        return wraps(f)(create_decorator(f, False))

    elif isinstance(f, types.MethodType):
        return wraps(f)(create_decorator(f.__func__, True))

    elif isinstance(f, partial):
        # wraps does not work for partials in 2.7: https://bugs.python.org/issue3445
        return wraps(f.func)(create_decorator(lambda *args, **kw: f(*args[1:], **kw), True))

    else:
        return create_decorator(f.__func__.__call__, True) 
开发者ID:lark-parser,项目名称:lark,代码行数:18,代码来源:json_parser.py

示例6: order_attributes

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def order_attributes(attrs):
    constants = {}
    functions = {}
    classes = {}
    
    for key, value in attrs.items():
        if isinstance(value, type(int.real)) or key in ("__abstractmethods__", "__base__", "__bases__", "__class__", "__dict__", "__dictoffset__", "__file__", "__flags__", "__itemsize__", "__module__", "__name__", "__package__", "__subclasses__", "__weakrefoffset__"):
            pass
        elif isinstance(value, (type, types.ClassType)):
            classes[key] = value
        elif isinstance(value, (types.FunctionType, types.BuiltinFunctionType, type(list.append), type(object.__init__), classmethod, staticmethod)):
            if not (key.startswith("__") and key.endswith("__")):
                functions[key] = value
        else:
            constants[key] = value
    
    constants = sorted_mapping(constants)
    functions = sorted_mapping(functions)
    classes = sorted_mapping(classes)
    classes_reverse = collections.OrderedDict((v, k) for k, v in classes.items())
    
    classes_ordered = collections.OrderedDict((classes_reverse[cls], cls) for cls in order_classes(classes.values()))
    
    return collections.OrderedDict(constants.items() + functions.items() + classes_ordered.items()) 
开发者ID:dgelessus,项目名称:pythonista-scripts,代码行数:26,代码来源:moduledump.py

示例7: stringify_attributes

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def stringify_attributes(attrs):
    lines = []
    
    for k, v in attrs.items():
        if isinstance(v, (type, types.ClassType)):
            lines.append(stringify_class(k, v))
        elif isinstance(v, (types.MethodType, type(list.append), type(object.__init__))):
            lines.append(stringify_method(k, v))
        elif isinstance(v, classmethod):
            lines.append(stringify_classmethod(k, v))
        elif isinstance(v, (types.FunctionType, types.BuiltinFunctionType, staticmethod)):
            lines.append(stringify_function(k, v))
        else:
            lines.append(stringify_constant(k, v))
    
    return u"\n".join(lines) 
开发者ID:dgelessus,项目名称:pythonista-scripts,代码行数:18,代码来源:moduledump.py

示例8: _decode_function

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def _decode_function(self, obj: dict) -> typing.Union[
            types.FunctionType, types.BuiltinFunctionType]:
        """
        Decode function

        Parameters
        ----------
        obj : dict
            dict to be decoded

        Returns
        -------
        typing.Union[types.FunctionType, types.BuiltinFunctionType]
            decoded function
        """
        # decode items in dict representation
        function_repr = self.decode(obj)
        return getattr(importlib.import_module(function_repr["module"]),
                       function_repr["name"]) 
开发者ID:delira-dev,项目名称:delira,代码行数:21,代码来源:codecs.py

示例9: __enter__

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def __enter__(self):
        next_envs = [env.copy() for env in self.envs]
        for env, next_env in zip(self.envs, next_envs):
            for (k, v) in env.items():
                if isinstance(v, (types.FunctionType, types.BuiltinFunctionType)):
                    if is_singledispatcher(v):
                        wrapper = self._transform_singledispatch(
                            v, self._wrap_fn)
                    else:
                        wrapper = self._wrap_fn(v)
                        if wrapper is v:
                            continue
                    next_env[k] = wrapper
                elif isinstance(v, type):
                    conditions = get_class_conditions(v)
                    if conditions.has_any():
                        self._wrap_class(v, conditions)
        for env, next_env in zip(self.envs, next_envs):
            env.update(next_env)
        return self 
开发者ID:pschanely,项目名称:CrossHair,代码行数:22,代码来源:enforce.py

示例10: _compute_fields_for_operation

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def _compute_fields_for_operation(self, fields, to_compute):
        row = OpRow(self)
        for name, tup in iteritems(fields):
            field, value = tup
            if isinstance(
                value,
                (
                    types.LambdaType,
                    types.FunctionType,
                    types.MethodType,
                    types.BuiltinFunctionType,
                    types.BuiltinMethodType,
                ),
            ):
                value = value()
            row.set_value(name, value, field)
        for name, field in to_compute:
            try:
                row.set_value(name, field.compute(row), field)
            except (KeyError, AttributeError):
                # error silently unless field is required!
                if field.required and name not in fields:
                    raise RuntimeError("unable to compute required field: %s" % name)
        return row 
开发者ID:web2py,项目名称:pydal,代码行数:26,代码来源:objects.py

示例11: short_repr

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def short_repr(obj):
    if isinstance(obj, (type, types.ModuleType, types.BuiltinMethodType,
                        types.BuiltinFunctionType)):
        return obj.__name__
    if isinstance(obj, types.MethodType):
        if obj.im_self is not None:
            return obj.im_func.__name__ + ' (bound)'
        else:
            return obj.im_func.__name__
    if isinstance(obj, (tuple, list, dict, set)):
        return '%d items' % len(obj)
    if isinstance(obj, weakref.ref):
        return 'all_weakrefs_are_one'
    return repr(obj)[:40] 
开发者ID:sippy,项目名称:rtp_cluster,代码行数:16,代码来源:objgraph.py

示例12: isbuiltin

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def isbuiltin(object):
    """Return true if the object is a built-in function or method.

    Built-in functions and methods provide these attributes:
        __doc__         documentation string
        __name__        original name of this function or method
        __self__        instance to which a method is bound, or None"""
    return isinstance(object, types.BuiltinFunctionType) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:10,代码来源:inspect.py

示例13: validate_aggregation

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def validate_aggregation(function):  # TODO: Recognize when need `reduce`
    if not isinstance(function,
                      (types.BuiltinFunctionType,
                       types.FunctionType,
                       types.LambdaType)):
        raise InvalidAggregationFunction("A function object is required.")

    if not (function.__code__.co_argcount >= 1):
        raise InvalidAggregationFunction("A function taking at least one argument is required") 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:11,代码来源:aggregations.py

示例14: validate_activation

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def validate_activation(function):
    if not isinstance(function,
                      (types.BuiltinFunctionType,
                       types.FunctionType,
                       types.LambdaType)):
        raise InvalidActivationFunction("A function object is required.")

    if function.__code__.co_argcount != 1:  # avoid deprecated use of `inspect`
        raise InvalidActivationFunction("A single-argument function is required.") 
开发者ID:CodeReclaimers,项目名称:neat-python,代码行数:11,代码来源:activations.py

示例15: __deepcopy__

# 需要导入模块: import types [as 别名]
# 或者: from types import BuiltinFunctionType [as 别名]
def __deepcopy__(self, memo):
        retVal = self.__class__()
        memo[id(self)] = retVal

        for attr in dir(self):
            if not attr.startswith('_'):
                value = getattr(self, attr)
                if not isinstance(value, (types.BuiltinFunctionType, types.FunctionType, types.MethodType)):
                    setattr(retVal, attr, copy.deepcopy(value, memo))

        for key, value in self.items():
            retVal.__setitem__(key, copy.deepcopy(value, memo))

        return retVal 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:16,代码来源:datatype.py


注:本文中的types.BuiltinFunctionType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。