mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Only print attributes that start with co_.
If passed a .py file as an argument, try to find its accompanying .pyc.
This commit is contained in:
parent
37c9351cf6
commit
ce0c19c4a8
1 changed files with 6 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue