"compiler" module py3k
I am trying to port a codebase which uses the "compiler" module from 2.x over to 3.1 ; I get an ImportError at
import compiler
as the module does not ex开发者_如何学运维ist in Python3.x ; Has the same functionality been integrated into another module within the standard library? Or has it been completely removed?
[EDIT]
I require an equivalent for compiler.parse.getChildren
in Py3k.
According to the docs, the module has been deprecated since 2.6 and been completely removed in 3.0.
From PEP 3108:
- Having to maintain both the built-in compiler and the stdlib package is redundant (24).
- The AST created by the compiler is available (23).
- Mechanism to compile from an AST needs to be added.
It depends on what you want to do. The abstract syntax tree stuff has largely been moved into the ast
module.
Apparently the compile built in function can compile an AST object to bytecode which (coarsely) handles the remaining functionality of the compiler
module. I've also never done this so YMMV.
精彩评论