Hi,
It is possible to get bytecode from code object.
Reversely, is it possible to create code object from bytecode?
ex.
## python code (not a module)
pycode = '''\
print ul\n
for item in items:
print li%s/li\n % item
print /ul\n
'''
## compile it and get bytecode
code =
[EMAIL PROTECTED] wrote:
It is possible to get bytecode from code object.
Reversely, is it possible to create code object from bytecode?
ex.
## python code (not a module)
pycode = '''\
print ul\n
for item in items:
print li%s/li\n % item
print /ul\n
'''
##
On Tue, 2006-12-26 at 11:15 -0800, [EMAIL PROTECTED] wrote:
Hi,
It is possible to get bytecode from code object.
Reversely, is it possible to create code object from bytecode?
ex.
## python code (not a module)
pycode = '''\
print ul\n
for item in items:
print li%s/li\n %
On Tue, 2006-12-26 at 14:48 -0500, Carsten Haese wrote:
* Code objects come in two flavors: statements and expressions.
* exec can execute a 'statement' flavored code object.
* eval can evaluate an 'expression' flavored code object.
* Your code snippet is a statement, actually, a suite of
Thanks Fredrik and Carsten,
I'll try marshal module.
* Your code snippet is a statement, actually, a suite of statements. You
need to exec it, not eval it.
* You seem to think that eval'ing or exec'ing a code object will
magically capture its output stream. It won't.
Oh, it's my mistake.