本文整理匯總了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))