from __future__ import ... within an RExec?

jepler at unpythonic.net jepler at unpythonic.net
Sun Aug 18 08:39:31 EDT 2002


You can get the behavior of __future__ options by passing a value to the
compile() builtin:
>>> import __future__
>>> print __future__.division
_Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)
>>> r.r_eval(compile('1/2', '<string>', 'eval', 8192, 0))
0.5
>>> r.r_eval(compile('1/2', '<string>', 'eval', 0, 0))
0

I'm not sure how to track the flags value you should pass to compile, and
it's a pain to wrap with compile(), but this shows it's possible to do what
you want.

Jeff





More information about the Python-list mailing list