Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82313
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <luciano@ramalho.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.041 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.00; 'subject:two': 0.07; 'ugly': 0.07; 'alternatives': 0.09; 'subject:()': 0.09; 'python': 0.11; 'arithmetic.': 0.16; 'coerced': 0.16; 'needless': 0.16; 'cheers,': 0.24; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'twitter:': 0.31; 'dropped': 0.31; 'subject:numbers': 0.31; 'url:python': 0.33; "i'd": 0.34; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'similar': 0.36; 'two': 0.37; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'numbers': 0.61; 'love': 0.65; 'situation': 0.65; 'series': 0.66; 'url:br': 0.69; 'url:pro': 0.84 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=1RqxPcOmQjdUDrHjEOAZVYHBug1WY1upT4qpzMX509I=; b=FYR+rxz14ZPIXJ7s5j4F8+lUC6u7d3tqawXBxKyribJvac2aCrACQTR9AH/qkvlTcz QKsrXJ7z+1QTqO+Gm+Igr8OEABPoAgssR4ecV6AHVdXvjIJgULYfD4L/r/FnBks00jxX wpHv9FJe0UeqnKTQutzVQpNh1tu2FCEyU1TnL8aAGRtwc/IeBZGslYQly2om6tYgTQKF +XR/b0dJHw1ndRNJ614W7fqUjxwe/s8cHlL8loo28D/CCcCft9+8BIsmp4qh5sABacjc omRM32aCbQqxPSQsBtWd9OeKcrAVrApbK4SVcsahrwGvZQs9CPuzgm4gLaojqcDEjMeO FUDA== |
| X-Gm-Message-State | ALoCoQmXxleXVwLISaaWSf7QEiVFIBzJe/pG6LddXFpS3w2pvBhmSf26HJuUQphAz/IxcEjbC7et |
| MIME-Version | 1.0 |
| X-Received | by 10.52.75.200 with SMTP id e8mr3701403vdw.47.1418250433601; Wed, 10 Dec 2014 14:27:13 -0800 (PST) |
| Date | Wed, 10 Dec 2014 20:27:13 -0200 |
| Subject | Coercing two numbers without coerce() |
| From | Luciano Ramalho <luciano@ramalho.org> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16829.1418250441.18130.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1418250441 news.xs4all.nl 2868 [2001:888:2000:d::a6]:46477 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 3464 |
| X-Received-Body-CRC | 2793530023 |
| Xref | csiph.com comp.lang.python:82313 |
Show key headers only | View raw
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