]> granicus.if.org Git - python/commitdiff
Only print attributes that start with co_.
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 17 Sep 2001 18:08:20 +0000 (18:08 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 17 Sep 2001 18:08:20 +0000 (18:08 +0000)
If passed a .py file as an argument, try to find its accompanying
.pyc.

Tools/compiler/dumppyc.py

index 4ab9821852e47803f969af3055b275668b3951f9..dd460c9911856d9a765ca8049d5b83d02aee15d8 100755 (executable)
@@ -1,13 +1,16 @@
 #! /usr/bin/env python
 
 import marshal
+import os
 import dis
 import types
 
 def dump(obj):
     print 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):
     f = open(path)
@@ -36,4 +39,6 @@ if __name__ == "__main__":
     else:
         filename = sys.argv[1]
         codename = None
+    if filename.endswith('.py') and os.path.exists(filename+"c"):
+        filename += "c"
     main(filename, codename)