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)
| 6025 | ##### Helper Functions #################################################### |
| 6026 | |
| 6027 | def _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 | |
| 6046 | def _convert_for_comparison(self, other, equality_op=False): |
| 6047 | """Given a Decimal instance self and a Python object other, return |
no test coverage detected