Turn off ZeroDivisionError?

Carl Banks pavlovevidence at gmail.com
Sun Feb 10 19:01:35 EST 2008


On Feb 10, 5:50 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> Mark Dickinson <dicki... at gmail.com> writes:
> > On Feb 10, 3:29 pm, Grant Edwards <gra... at visi.com> wrote:
> > > platform does".  Except it doesn't in cases like this. All my
> > > platforms do exactly what I want for division by zero: they
> > > generate a properly signed INF.  Python chooses to override
> > > that (IMO correct) platform behavior with something surprising.
> > > Python doesn't generate exceptions for other floating point
> > > "events" -- why the inconsistency with divide by zero?
>
> > But not everyone wants 1./0. to produce an infinity;  some people
> > would prefer an exception.
>
> Special cases aren't special enough to break the rules.
>
> Most people would not want this behaviour either::
>
>     >>> 0.1
>     0.10000000000000001
>
> But the justification for this violation of surprise is "Python just
> does whatever the underlying hardware does with floating-point
> numbers". If that's the rule, it shouldn't be broken in the special
> case of division by zero.

Do you recall what the very next Zen after "Special cases aren't
special enough to break the rules" is?


that's-why-they-call-it-Zen-ly yr's,

Carl Banks




More information about the Python-list mailing list