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)
| 5992 | ##### Helper Functions #################################################### |
| 5993 | |
| 5994 | def _convert_other(other, raiseit=False, allow_float=False): |
| 5995 | """Convert other to Decimal. |
| 5996 | |
| 5997 | Verifies that it's ok to use in an implicit construction. |
| 5998 | If allow_float is true, allow conversion from float; this |
| 5999 | is used in the comparison methods (__eq__ and friends). |
| 6000 | |
| 6001 | """ |
| 6002 | if isinstance(other, Decimal): |
| 6003 | return other |
| 6004 | if isinstance(other, int): |
| 6005 | return Decimal(other) |
| 6006 | if allow_float and isinstance(other, float): |
| 6007 | return Decimal.from_float(other) |
| 6008 | |
| 6009 | if raiseit: |
| 6010 | raise TypeError("Unable to convert %s to Decimal" % other) |
| 6011 | return NotImplemented |
| 6012 | |
| 6013 | def _convert_for_comparison(self, other, equality_op=False): |
| 6014 | """Given a Decimal instance self and a Python object other, return |
no test coverage detected
searching dependent graphs…