Coercing two numbers without coerce()
Chris Angelico
rosuav at gmail.com
Wed Dec 10 17:32:12 EST 2014
On Thu, Dec 11, 2014 at 9:27 AM, Luciano Ramalho <luciano at ramalho.org> wrote:
> I know I can do type(A+B)(A), or A+B-B, but both alternatives are ugly
> and perform needless arithmetic.
>
> What do you suggest, now that the coerce() built-in is not available?
I would suggest just doing the arithmetic :) That's guaranteed to
work, and a little addition isn't that costly. (As long as you're not
Numberphile and implementing four-bit binary arithmetic in racing
dominoes. Then it's costly.)
ChrisA
More information about the Python-list
mailing list