Re: Coercing two numbers without coerce()

2014-12-10 Thread Steven D'Aprano
On Wed, 10 Dec 2014 20:27:13 -0200, Luciano Ramalho wrote: > Python 3 dropped the coerce() built-in, but I have a situation where I'd > love to use it. > > I have two numbers A, B and I need to get the value of A coerced to the > type of A+B. This is for a generator function that will produce a s

Re: Coercing two numbers without coerce()

2014-12-10 Thread Chris Angelico
On Thu, Dec 11, 2014 at 9:27 AM, Luciano Ramalho 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 guarant