本文整理汇总了Python中operator.__truediv__方法的典型用法代码示例。如果您正苦于以下问题:Python operator.__truediv__方法的具体用法?Python operator.__truediv__怎么用?Python operator.__truediv__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类operator
的用法示例。
在下文中一共展示了operator.__truediv__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _string_to_operator
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def _string_to_operator(self):
operators = {
"+": operator.__add__,
"-": operator.__sub__,
"*": operator.__mul__,
"**": operator.__pow__,
"/": operator.__truediv__,
"//": operator.__floordiv__,
}
return operators[self.operator]
### PUBLIC PROPERTIES ###
示例2: __truediv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def __truediv__(self, other):
return self._operation(other, operator.__truediv__)
示例3: __rtruediv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def __rtruediv__(self, other):
return self._roperation(other, operator.__truediv__)
示例4: __truediv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def __truediv__(self, other):
assert isinstance(other, float) or isinstance(other, int) or isinstance(other, bool) or isinstance(other, Point)
if isinstance(other, Point):
return Point(__truediv__(self.x, other.x), __truediv__(self.y, other.y))
else:
return Point(__truediv__(self.x, other), __truediv__(self.y, other))
示例5: __div__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def __div__(self, other):
return self.__truediv__(other)
示例6: __rtruediv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import __truediv__ [as 别名]
def __rtruediv__(self, other):
assert isinstance(other, float) or isinstance(other, int) or isinstance(other, bool)
return Point(__truediv__(other, self.x), __truediv__(other, self.y))