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


Python W_NumericObject.retry_binop_coercing方法代码示例

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


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

示例1: method

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
 def method(self, space, w_other):
     if space.is_kind_of(w_other, space.w_float):
         return space.newbool(func(self.intvalue, space.float_w(w_other)))
     elif space.is_kind_of(w_other, space.w_fixnum):
         return space.newbool(func(self.intvalue, space.int_w(w_other)))
     else:
         return W_NumericObject.retry_binop_coercing(space, self, w_other, name, raise_error=True)
开发者ID:Alexis-D,项目名称:topaz,代码行数:9,代码来源:intobject.py

示例2: method_divide

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
 def method_divide(self, space, w_other):
     if space.is_kind_of(w_other, space.w_fixnum):
         return self.floordiv(space, rbigint.fromint(space.int_w(w_other)))
     elif space.is_kind_of(w_other, space.w_bignum):
         return self.floordiv(space, space.bigint_w(w_other))
     elif space.is_kind_of(w_other, space.w_float):
         return space.send(space.newfloat(space.float_w(self)), "/", [w_other])
     else:
         return W_NumericObject.retry_binop_coercing(space, self, w_other, "/")
开发者ID:jeffhsu3,项目名称:topaz,代码行数:11,代码来源:bignumobject.py

示例3: method

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
 def method(self, space, w_other):
     w_other = space.convert_type(w_other, space.w_integer, "to_int")
     if space.is_kind_of(w_other, space.w_fixnum):
         other = space.int_w(w_other)
         return space.newint(func(self.intvalue, other))
     elif space.is_kind_of(w_other, space.w_bignum):
         return space.send(space.newbigint_fromint(self.intvalue), name, [w_other])
     else:
         return W_NumericObject.retry_binop_coercing(space, self, w_other, name)
开发者ID:babelsberg,项目名称:babelsberg-r,代码行数:11,代码来源:intobject.py

示例4: method_eq

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
    def method_eq(self, space, w_other):
        if space.is_kind_of(w_other, space.w_float):
            return space.newbool(self.floatvalue == space.float_w(w_other))

        try:
            return W_NumericObject.retry_binop_coercing(space, self, w_other, "==")
        except RubyError as e:
            if isinstance(e.w_value, W_ArgumentError):
                return space.send(w_other, "==", [self])
            else:
                raise
开发者ID:dadadadave,项目名称:topaz,代码行数:13,代码来源:floatobject.py

示例5: divide

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
 def divide(self, space, w_other):
     if space.is_kind_of(w_other, space.w_fixnum):
         other = space.int_w(w_other)
         try:
             return space.newint(self.intvalue / other)
         except ZeroDivisionError:
             self.raise_zero_division_error(space)
     elif space.is_kind_of(w_other, space.w_bignum):
         return space.send(space.newbigint_fromint(self.intvalue), space.newsymbol("/"), [w_other])
     elif space.is_kind_of(w_other, space.w_float):
         return space.send(space.newfloat(space.float_w(self)), space.newsymbol("/"), [w_other])
     else:
         return W_NumericObject.retry_binop_coercing(space, self, w_other, "/")
开发者ID:haramako,项目名称:topaz,代码行数:15,代码来源:intobject.py

示例6: method_fdiv

# 需要导入模块: from topaz.objects.numericobject import W_NumericObject [as 别名]
# 或者: from topaz.objects.numericobject.W_NumericObject import retry_binop_coercing [as 别名]
 def method_fdiv(self, space, w_other):
     if space.is_kind_of(w_other, space.w_fixnum):
         other = space.int_w(w_other)
         try:
             res = float(self.intvalue) / float(other)
         except ZeroDivisionError:
             return space.newfloat(rfloat.copysign(rfloat.INFINITY, float(self.intvalue)))
         else:
             return space.newfloat(res)
     elif space.is_kind_of(w_other, space.w_bignum):
         return space.send(space.newbigint_fromint(self.intvalue), "fdiv", [w_other])
     elif space.is_kind_of(w_other, space.w_float):
         other = space.float_w(w_other)
         try:
             res = float(self.intvalue) / other
         except ZeroDivisionError:
             return space.newfloat(rfloat.copysign(rfloat.INFINITY, float(self.intvalue)))
         else:
             return space.newfloat(res)
     else:
         return W_NumericObject.retry_binop_coercing(space, self, w_other, "fdiv")
开发者ID:babelsberg,项目名称:babelsberg-r,代码行数:23,代码来源:intobject.py


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