user277465
user277465

Reputation:

"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 exist 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.

Upvotes: 8

Views: 1732

Answers (2)

aaronasterling
aaronasterling

Reputation: 70984

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.

Upvotes: 5

Tim Pietzcker
Tim Pietzcker

Reputation: 336078

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.

Upvotes: 7

Related Questions