Hi,
I would like to compile an AST to bytecode, so I can eval it later. I
tried using parse.compileast, but it fails:
import compiler, parser
ast = compiler.parse(42)
parser.compileast(ast)
Traceback (most recent call last):
File stdin, line 1, in ?
TypeError: compilest() argument 1 must
Rob De Almeida [EMAIL PROTECTED] wrote:
I would like to compile an AST to bytecode, so I can eval it later. I
tried using parse.compileast, but it fails:
import compiler, parser
ast = compiler.parse(42)
parser.compileast(ast)
Traceback (most recent call last):
File stdin, line 1
Duncan Booth wrote:
I would like to compile an AST to bytecode, so I can eval it later.
I'm not sure there are any properly documented functions for converting an
AST to a code object, so your best bet may be to examine what a
pycodegen class like Expression or Module actually does.
Thanks
Rob De Almeida wrote:
Duncan Booth wrote:
I would like to compile an AST to bytecode, so I can eval it later.
I'm not sure there are any properly documented functions for converting an
AST to a code object, so your best bet may be to examine what a
pycodegen class like Expression