[Python Wpg] Fwd: Cannot figure out this ZeroDivisionError exception

Chris Macksey cmacksey at gmail.com
Fri Mar 11 20:22:57 EST 2011


On 11 March 2011 18:38, Mike pfaiffer <high.res.mike at gmail.com> wrote:

>
>        Just a thought. Would scale = 1/300 not produce 0 instead of the
> floating point 0.00333? It looks like you may have a data type conversion
> issue. If the numerator is an integer then the result of the division will
> be an integer. I was caught by this a couple of times (and will no doubt be
> caught by it again in the future).
>
>                                Later
>                                Mike
>
>

Yes, it would, depending on your Python version - unless you either use from
__future__ import division  to get the new division semantics, or use
1.0/300 (or equivalent) to force it to be a float.

Cheers,

Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/winnipeg/attachments/20110311/01aa8264/attachment.html>


More information about the Winnipeg mailing list