On 6/10/2013 11:33 AM, dhyams wrote:
The built-in compile() function has a "flags" parameter that one can
use to influence the "__future__" mechanism. However,
py_compile.compile, which I'm using to byte-compile code, doesn't
have an equivalent means to do this.

That flag was added to compile bacause it is needed to compile expressions and single statements, whether in string or ast form, that use future syntax. It is impossible to include a future statement with either. It is not needed for compiling multiple statements.

Is this by design, or would this be considered a bug?

Design, not needed.

import __future__
py_compile.compile("foobar.py",flags=__future__.CO_FUTURE_DIVISION)

Put the future statement inside foobar.py just as you would do if running it from the command line. Notice that there is no command-line future flag either.

Terry



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to