durusmail: quixote-users: Patch to protect against future changes to integer division semantics
Patch to protect against future changes to integer division semantics
2004-04-18
Patch to protect against future changes to integer division semantics
2004-04-18
2004-04-18
Patch to protect against future changes to integer division semantics
2004-04-18
Patch to protect against future changes to integer division semantics
rmunn@pobox.com
2004-04-18
On Sun, Apr 18, 2004 at 04:50:23PM +0400, Oleg Broytmann wrote:
> On Sun, Apr 18, 2004 at 07:33:21AM -0500, rmunn@pobox.com wrote:
> >  import time
> >  from rfc822 import formatdate
> >  from types import StringType, IntType
> > +try:
> > +    from __future__ import division
> > +except SyntaxError:
> > +    _new_division = 0
> > +else:
> > +    _new_division = 1
>
>    Have you tested it? This should not work - "from __future__" is
> comiler directive and must be the first statement in a module. Really
> the first - even try is not allowed. I.e. you cannot protect
> "__future__"...

You're absolutely right; I tested it in the interactive interpreter,
where the above construction did work -- but running that in a separate
.py file, it does not.

Jim Dukarm's suggestion of dropping the division and using modulo is a
good one, though, and would have been better (i.e. simpler) than my
proposed patch even were it not for the fact that mine doesn't work. :-)

--
Robin Munn
rmunn@pobox.com


reply