[Python-ideas] Python Numbers as Human Concept Decimal System
Chris Angelico
rosuav at gmail.com
Sun Mar 9 01:07:21 CET 2014
On Sun, Mar 9, 2014 at 10:48 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> It might be possible to experiment with this in Idle. It already does some
> parsing of user input as typed in order to color code it, though that may
> not recognize float literals. If not, let float_lit = <re that recognizes
> float literals>. Then use re.sub to replace 'xx.yy', etc, with 'D("xx.yy")'
> before sending user input to the subprocess. When auto-decimal mode is set,
> display and send 'from decimal import Decimal as D' to the user-process and
> change the prompt to, for instance
I played with the possibility of an AST transform, but by the time
it's compiled into an AST, it's too late - the string has already been
floated. A regex would be a fairly hefty hammer, I think.
ChrisA
More information about the Python-ideas
mailing list