Future division patch available (PEP 238)

Anders J. Munch andersjm at dancontrol.dk
Mon Aug 20 08:32:35 EDT 2001


"Christian Tanzer" <tanzer at swing.co.at> wrote:
> "Anders J. Munch" <andersjm at dancontrol.dk> wrote:
>
> > 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.
>
> Do you really want to replace things like
>
>     """...text and/or more text..."""
>
> by
>
>     """...text and__oldstyle_divide__or more text..."""

No.  You can tell / division apart from / in comments and strings by
means of lexical analysis, which is much simpler than a full parse for
a syntactically clean language such as Python.

> OTOH, literal strings like "period / 2" might need replacement.

Well, only if used, directly or indirectly, with 'exec' or 'eval'.
Like doctest code.  Not a big problem though AFAICT.  Leave it
untouched, and if the tests get run then the test failure should alert
someone that the code needs fixing, and if the tests don't get run
everything will work fine.

>And
> how about comments?

Comments would be left untouched.

might-even-volunteer-to-do-the-job-myself-ly-y'rs,
Anders





More information about the Python-list mailing list