Compile AST to bytecode?

2006-09-19 Thread Rob De Almeida
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

Re: Compile AST to bytecode?

2006-09-19 Thread Duncan Booth
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

Re: Compile AST to bytecode?

2006-09-19 Thread Rob De Almeida
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

Re: Compile AST to bytecode?

2006-09-19 Thread fumanchu
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