Commit 2b468893 authored by Jeremy Hylton's avatar Jeremy Hylton

Only print attributes that start with co_.

If passed a .py file as an argument, try to find its accompanying
.pyc.
parent ae096387
#! /usr/bin/env python #! /usr/bin/env python
import marshal import marshal
import os
import dis import dis
import types import types
def dump(obj): def dump(obj):
print obj print obj
for attr in dir(obj): for attr in dir(obj):
print "\t", attr, repr(getattr(obj, attr)) if attr.startswith('co_'):
val = getattr(obj, attr)
print "\t", attr, repr(val)
def loadCode(path): def loadCode(path):
f = open(path) f = open(path)
...@@ -36,4 +39,6 @@ if __name__ == "__main__": ...@@ -36,4 +39,6 @@ if __name__ == "__main__":
else: else:
filename = sys.argv[1] filename = sys.argv[1]
codename = None codename = None
if filename.endswith('.py') and os.path.exists(filename+"c"):
filename += "c"
main(filename, codename) main(filename, codename)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment