Python operator.__truediv__() Examples

The following are 6 code examples of operator.__truediv__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module operator , or try the search function .
Example #1
Source File: lineroot.py    From backtrader with GNU General Public License v3.0 5 votes vote down vote up
def __truediv__(self, other):
        return self._operation(other, operator.__truediv__) 
Example #2
Source File: lineroot.py    From backtrader with GNU General Public License v3.0 5 votes vote down vote up
def __rtruediv__(self, other):
        return self._roperation(other, operator.__truediv__) 
Example #3
Source File: Pbinop.py    From supriya with MIT License 5 votes vote down vote up
def _string_to_operator(self):
        operators = {
            "+": operator.__add__,
            "-": operator.__sub__,
            "*": operator.__mul__,
            "**": operator.__pow__,
            "/": operator.__truediv__,
            "//": operator.__floordiv__,
        }
        return operators[self.operator]

    ### PUBLIC PROPERTIES ### 
Example #4
Source File: point.py    From ShapeWorld with MIT License 5 votes vote down vote up
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)) 
Example #5
Source File: point.py    From ShapeWorld with MIT License 5 votes vote down vote up
def __div__(self, other):
        return self.__truediv__(other) 
Example #6
Source File: point.py    From ShapeWorld with MIT License 5 votes vote down vote up
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))