Future division patch available (PEP 238)

Anders J. Munch andersjm at dancontrol.dk
Thu Aug 16 09:26:23 EDT 2001


"Terry Reedy" <tjreedy at home.com> wrote:
>
> "Anders J. Munch" <andersjm at dancontrol.dk> wrote:
> > Here's an idea on how to avoid that: Replace each instance of / and
> /=
> > with a call to a function that emulates old division behaviour. This
> > could be completely automated.

> To automate this, you need a parser that can accurately recognize the
> blocks of text that correspond to E1 and E2.

Right. It only needs to be done once though, and since CPython,
JPython and PyChecker must already know how to parse Python, for the
right people this shouldn't be too hard.

Another option would be to add a new infix operator to the language
with the same precedence as /. Something with a long clunky name, like
"__oldstyle_divide__", whose only raison d'être is compatibility
hacks. Changing
    E1 / E2
to
    E1 __oldstyle_divide__ E2
doesn't require deep parsing.

- Anders





More information about the Python-list mailing list