Nasty typo in PEP 238 (revised)
bokr at accessone.com
Sat Jul 28 02:59:13 EDT 2001
On Fri, 27 Jul 2001 17:53:28 GMT, Andrew Koenig <ark at research.att.com> wrote:
>David> In article <cp4rrz5onj.fsf at cj20424-a.reston1.va.home.com>,
>David> Guido van Rossum <guido at python.org> wrote:
>>> Q. How do I write code that works under the classic rules as well
>>> as under the new rules without using // or a future division
>>> A. Use x*1.0/y for true division, divmod(x, y) for int
>>> division. Especially the latter is best hidden inside a
>>> function. You may also write floor(x)/y for true division if
>>> you are sure that you don't expect complex numbers.
>David> Shouldn't this be float(x)/y ?
>What if x is complex?
Why couldn't float apply like a scalar multiply? I.e., do it
to both real and imaginary values separately.
It won't do for abs() and such, but float() is just a numeric
representation control with possible exactness effects.
int() could be viewed that way too. floor() and ceil() could bring
things to integer grid points, if that makes sense.
More information about the Python-list