470,815 Members | 3,163 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

code-object

LG
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 ?
like the one on .pyc

Regards
LG
Feb 21 '07 #1
2 1051
En Tue, 20 Feb 2007 22:39:43 -0300, LG <lg**@optonline.netescribió:
>>>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 ?
like the one on .pyc
Do you want the source code back? You need a decompiler. decompyle may
work but it's outdated.

--
Gabriel Genellina

Feb 21 '07 #2
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

Feb 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

51 posts views Thread by Mudge | last post: by
4 posts views Thread by jason | last post: by
16 posts views Thread by Dario de Judicibus | last post: by
109 posts views Thread by Andrew Thompson | last post: by
171 posts views Thread by tshad | last post: by
29 posts views Thread by John Rivers | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.