Is there a way to execute an
Grab the compiler flag for
__future__.division, pass it and your code to
compile(), then run
eval() on the returned code object.
(note by mh) This has the added advantage of not changing the division operation globally, which might have unexpected side effects. (end note)
>>> import __future__ >>> eval(compile('1/3', '<string>', 'eval', __future__.division.compiler_flag)) 0.33333333333333331