Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82313
| Date | 2014-12-10 20:27 -0200 |
|---|---|
| Subject | Coercing two numbers without coerce() |
| From | Luciano Ramalho <luciano@ramalho.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16829.1418250441.18130.python-list@python.org> (permalink) |
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 series similar to what itertools.count does. 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? Cheers, Luciano -- Luciano Ramalho Twitter: @ramalhoorg Professor em: http://python.pro.br Twitter: @pythonprobr
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Coercing two numbers without coerce() Luciano Ramalho <luciano@ramalho.org> - 2014-12-10 20:27 -0200 Re: Coercing two numbers without coerce() Steven D'Aprano <steve@pearwood.info> - 2014-12-11 03:35 +0000
csiph-web