[Python-Dev] Floor division

Nick Maclaren nmm1 at cus.cam.ac.uk
Tue Jan 23 18:35:50 CET 2007


"Jim Jewett" <jimjjewett at gmail.com> wrote:
>
> >... I can work with and teach almost any model,
> > and have done so with some pretty weird ones.
>
> I think python's model is "Whatever your other tools use.  Ask them."
> And I think that is a reasonable choice.

Answer:  It's undefined.  Just because you have tested your code
today doesn't mean it will work tomorrow, or on a different set of
values (however similar), or that it will give the same answer
every time you do the same operation on the same input, or that the
effects will be limited to wrong answers and stray exceptions.

Still think that it is reasonable?

> > Some people write Python that is intended to be robust and portable;
> > it is those people who suffer.
> 
> If your users stick to sensible inputs, then it doesn't matter which
> model you used.

Sigh.  Let's step back a step.  Who decides when inputs are sensible?
And where is it documented?  Answers:  God alone knows, and nowhere.

One of Python's general principles is that its operations should
either do roughly what a reasonable user would expect, or it will
raise an exception.  It doesn't always get there, but it isn't bad.
What you are saying is that is undesirable.

The old Fortran and C model of saying that any user error can cause
any effect (including nasal demons) is tolerable only if there is
agreement on what IS an error, and there is some way for a user to
find that out.  In the case of C, neither is true.

> If not, there is no way to get robust and portable; it is just a
> matter of which users you annoy.

Well, actually, there is.  Though I agree that the techniques have
rather been forgotten in the past 30 years.  Python implements more
of them than most languages.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679


More information about the Python-Dev mailing list