Future division patch available (PEP 238)
Terry Reedy
tjreedy at home.com
Wed Aug 15 15:29:53 EDT 2001
"Anders J. Munch" <andersjm at dancontrol.dk> wrote in message
news:3b7a782f$0$250$edfadb0f at dspool01.news.tele.dk...
> 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.
>
> That is replace each instance of
> E1 / E2
> where E1 and E2 are arbitrary expressions, with
> oldstyle_division(E1,E2)
>
> def oldstyle_division(E1,E2):
> if type(E1) == types.IntType and type(E2) == types.IntType:
> return E1 // E2
> else:
> return E1 / E2
To automate this, you need a parser that can accurately recognize the
blocks of text that correspond to E1 and E2. The difficulty in doing
this is one reason for // instead of div(,).
Terry J. Reedy
More information about the Python-list
mailing list