from __future__ import ... within an RExec?

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Sun Aug 18 06:51:06 CEST 2002


Erik Max Francis <max at alcyone.com> writes:
> > Use x.r_eval(1.0/2.0).
> 
> Um, I know how to do float division.  I'd like the / operator itself to
> exhibit float division behavior.  I'm well aware of how to do float
> division between two numbers; third parties are entering in expressions
> to be evaluated and would prefer that the / operator exhibits float
> division behavior rather than integer division.

How about:

result = eval(re.sub("/","*1.0/", expression))



More information about the Python-list mailing list