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


Python operator.__name__方法代码示例

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


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

示例1: visit_unary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def visit_unary(self, unary, **kw):
        if unary.operator:
            if unary.modifier:
                raise exc.CompileError(
                    "Unary expression does not support operator "
                    "and modifier simultaneously")
            disp = getattr(self, "visit_%s_unary_operator" %
                           unary.operator.__name__, None)
            if disp:
                return disp(unary, unary.operator, **kw)
            else:
                return self._generate_generic_unary_operator(
                    unary, OPERATORS[unary.operator], **kw)
        elif unary.modifier:
            disp = getattr(self, "visit_%s_unary_modifier" %
                           unary.modifier.__name__, None)
            if disp:
                return disp(unary, unary.modifier, **kw)
            else:
                return self._generate_generic_unary_modifier(
                    unary, OPERATORS[unary.modifier], **kw)
        else:
            raise exc.CompileError(
                "Unary expression has no operator or modifier") 
开发者ID:gltn,项目名称:stdm,代码行数:26,代码来源:compiler.py

示例2: visit_binary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def visit_binary(self, binary, **kw):
        # don't allow "? = ?" to render
        if self.ansi_bind_rules and \
                isinstance(binary.left, elements.BindParameter) and \
                isinstance(binary.right, elements.BindParameter):
            kw['literal_binds'] = True

        operator = binary.operator
        disp = getattr(self, "visit_%s_binary" % operator.__name__, None)
        if disp:
            return disp(binary, operator, **kw)
        else:
            try:
                opstring = OPERATORS[operator]
            except KeyError:
                raise exc.UnsupportedCompilationError(self, operator)
            else:
                return self._generate_generic_binary(binary, opstring, **kw) 
开发者ID:gltn,项目名称:stdm,代码行数:20,代码来源:compiler.py

示例3: visit_unary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def visit_unary(self, unary, **kw):
        if unary.operator:
            if unary.modifier:
                raise exc.CompileError(
                        "Unary expression does not support operator "
                        "and modifier simultaneously")
            disp = getattr(self, "visit_%s_unary_operator" %
                                    unary.operator.__name__, None)
            if disp:
                return disp(unary, unary.operator, **kw)
            else:
                return self._generate_generic_unary_operator(unary,
                                    OPERATORS[unary.operator], **kw)
        elif unary.modifier:
            disp = getattr(self, "visit_%s_unary_modifier" %
                                    unary.modifier.__name__, None)
            if disp:
                return disp(unary, unary.modifier, **kw)
            else:
                return self._generate_generic_unary_modifier(unary,
                                    OPERATORS[unary.modifier], **kw)
        else:
            raise exc.CompileError(
                            "Unary expression has no operator or modifier") 
开发者ID:binhex,项目名称:moviegrabber,代码行数:26,代码来源:compiler.py

示例4: visit_binary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def visit_binary(self, binary, **kw):
        # don't allow "? = ?" to render
        if self.ansi_bind_rules and \
            isinstance(binary.left, elements.BindParameter) and \
            isinstance(binary.right, elements.BindParameter):
            kw['literal_binds'] = True

        operator = binary.operator
        disp = getattr(self, "visit_%s_binary" % operator.__name__, None)
        if disp:
            return disp(binary, operator, **kw)
        else:
            try:
                opstring = OPERATORS[operator]
            except KeyError:
                raise exc.UnsupportedCompilationError(self, operator)
            else:
                return self._generate_generic_binary(binary, opstring, **kw) 
开发者ID:binhex,项目名称:moviegrabber,代码行数:20,代码来源:compiler.py

示例5: __repr__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def __repr__(self):
        friendly = self.description
        if friendly is None:
            return object.__repr__(self)
        else:
            return "<%s.%s at 0x%x; %s>" % (
                self.__module__,
                self.__class__.__name__,
                id(self),
                friendly,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:13,代码来源:elements.py

示例6: __getattr__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def __getattr__(self, key):
        try:
            return getattr(self.comparator, key)
        except AttributeError as err:
            util.raise_(
                AttributeError(
                    "Neither %r object nor %r object has an attribute %r"
                    % (
                        type(self).__name__,
                        type(self.comparator).__name__,
                        key,
                    )
                ),
                replace_context=err,
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:17,代码来源:elements.py

示例7: _construct

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def _construct(cls, operator, continue_on, skip_on, *clauses, **kw):
        lcc, convert_clauses = cls._process_clauses_for_boolean(
            operator,
            continue_on,
            skip_on,
            [
                coercions.expect(roles.WhereHavingRole, clause)
                for clause in util.coerce_generator_arg(clauses)
            ],
        )

        if lcc > 1:
            # multiple elements.  Return regular BooleanClauseList
            # which will link elements against the operator.
            return cls._construct_raw(operator, convert_clauses)
        elif lcc == 1:
            # just one element.  return it as a single boolean element,
            # not a list and discard the operator.
            return convert_clauses[0]
        else:
            # no elements period.  deprecated use case.  return an empty
            # ClauseList construct that generates nothing unless it has
            # elements added to it.
            util.warn_deprecated(
                "Invoking %(name)s() without arguments is deprecated, and "
                "will be disallowed in a future release.   For an empty "
                "%(name)s() construct, use %(name)s(%(continue_on)s, *args)."
                % {
                    "name": operator.__name__,
                    "continue_on": "True"
                    if continue_on is True_._singleton
                    else "False",
                },
                version="1.4",
            )
            return cls._construct_raw(operator) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:38,代码来源:elements.py

示例8: _scalar

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def _scalar(self, operator, scalar, reverse=False):
        cart = self._to_cartesian()
        if not isinstance(scalar, (numbers.Number, self.awkward.numpy.number)):
            raise TypeError("cannot {0} a TLorentzVector with a {1}".format(operator.__name__, type(scalar).__name__))
        if reverse:
            return TLorentzVector(operator(scalar, cart.x), operator(scalar, cart.y), operator(scalar, cart.z), operator(scalar, cart.t))
        else:
            return TLorentzVector(operator(cart.x, scalar), operator(cart.y, scalar), operator(cart.z, scalar), operator(cart.t, scalar)) 
开发者ID:scikit-hep,项目名称:uproot-methods,代码行数:10,代码来源:TLorentzVector.py

示例9: _vector

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __name__ [as 别名]
def _vector(self, operator, vector, reverse=False):
        cart = self._to_cartesian()
        if not isinstance(vector, Methods):
            raise TypeError("cannot {0} a TLorentzVector with a {1}".format(operator.__name__, type(vector).__name__))
        if reverse:
            return TLorentzVector(operator(vector.x, cart.x), operator(vector.y, cart.y), operator(vector.z, cart.z), operator(vector.t, cart.t))
        else:
            return TLorentzVector(operator(cart.x, vector.x), operator(cart.y, vector.y), operator(cart.z, vector.z), operator(cart.t, vector.t)) 
开发者ID:scikit-hep,项目名称:uproot-methods,代码行数:10,代码来源:TLorentzVector.py


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