MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _convert_other

Function _convert_other

tools/python-3.11.9-amd64/Lib/_pydecimal.py:6027–6044  ·  view source on GitHub ↗

Convert other to Decimal. Verifies that it's ok to use in an implicit construction. If allow_float is true, allow conversion from float; this is used in the comparison methods (__eq__ and friends).

(other, raiseit=False, allow_float=False)

Source from the content-addressed store, hash-verified

6025##### Helper Functions ####################################################
6026
6027def _convert_other(other, raiseit=False, allow_float=False):
6028 """Convert other to Decimal.
6029
6030 Verifies that it's ok to use in an implicit construction.
6031 If allow_float is true, allow conversion from float; this
6032 is used in the comparison methods (__eq__ and friends).
6033
6034 """
6035 if isinstance(other, Decimal):
6036 return other
6037 if isinstance(other, int):
6038 return Decimal(other)
6039 if allow_float and isinstance(other, float):
6040 return Decimal.from_float(other)
6041
6042 if raiseit:
6043 raise TypeError("Unable to convert %s to Decimal" % other)
6044 return NotImplemented
6045
6046def _convert_for_comparison(self, other, equality_op=False):
6047 """Given a Decimal instance self and a Python object other, return

Callers 15

compareMethod · 0.85
__add__Method · 0.85
__sub__Method · 0.85
__rsub__Method · 0.85
__mul__Method · 0.85
__truediv__Method · 0.85
__rtruediv__Method · 0.85
__divmod__Method · 0.85
__rdivmod__Method · 0.85
__mod__Method · 0.85
__rmod__Method · 0.85
remainder_nearMethod · 0.85

Calls 2

DecimalClass · 0.85
from_floatMethod · 0.45

Tested by

no test coverage detected