By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,766 Members | 1,317 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,766 IT Pros & Developers. It's quick & easy.

python compile code object -- reverse how to

P: n/a
leo
Hi,
following is the python scripts:
import marshal
script = """
print 'hello'
"""
code = compile(script, "<script>", "exec")
data = marshal.dumps(code)
print repr(data)
the result:'c\000\000\000\000\001\000\000\000s\017\000 \000\00
0\177\000\000\177\002\000d\000\000GHd\001\000S(\00
2\000\000\000s\005\000\000\000helloN(\000\000\000\
000(\000\000\000\000s\010\000\000\000<script>s\001
\000\000\000?\002\000s\000\000\000\000'how to convert the result code to
orig script """print 'hello'"""thanks
Jul 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
leo
Hi, all,
i mean to convert
'c\000\000\000\000\001\000\000\000s\017\000\000\00
0\177\000\000\177\002\000d\000\000GHd\001\000S(\00
2\000\000\000s\005\000\000\000helloN(\000\000\000\
000(\000\000\000\000s\010\000\000\000<script>s\001 '
to the orig script
""" print 'hello' """

Thanks

"leo" <lg**@optonline.netwrote in message
news:nt**************@fe09.lga...
Hi,
following is the python scripts:
import marshal
script = """
print 'hello'
"""
code = compile(script, "<script>", "exec")
data = marshal.dumps(code)
print repr(data)
the result:'c\000\000\000\000\001\000\000\000s\017\000 \000\00
0\177\000\000\177\002\000d\000\000GHd\001\000S(\00
2\000\000\000s\005\000\000\000helloN(\000\000\000\
000(\000\000\000\000s\010\000\000\000<script>s\001
\000\000\000?\002\000s\000\000\000\000'how to convert the result code to
orig script """print 'hello'"""thanks


Jul 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.