code-object

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Tue Feb 20 23:19:19 EST 2007


On Tue, 20 Feb 2007 20:39:43 -0500, LG wrote:

> Hi, All,
> 
>>>>code = compile('print "hello everyone, how are you? "', '<string>',
> 'exec')
>>>>exec code
> hello everyone, how are you?
>>>>print code
> <code object ? at 0x8122d70, file "<string>", line 1>
> 
> how to print the code object ?

You just did.

> like the one on .pyc

What do you mean? 

What output do you want to see?

Does this help?

>>> import dis
>>> code = compile("print 'hello world'", "string", "exec")
>>> dis.dis(code)
  1           0 LOAD_CONST               0 ('hello world')
              3 PRINT_ITEM
              4 PRINT_NEWLINE
              5 LOAD_CONST               1 (None)
              8 RETURN_VALUE



-- 
Steven D'Aprano 




More information about the Python-list mailing list