diff options
author | Guido van Rossum <guido@python.org> | 1997-03-14 04:15:43 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-03-14 04:15:43 (GMT) |
commit | 18aef3c10214fba136da7ccee30932b8aab4cb97 (patch) | |
tree | e1a3563aa12934083e84c9758d73860eb352cf02 | |
parent | 7b7c5786161d9d443d13f56276620519587a2624 (diff) | |
download | cpython-18aef3c10214fba136da7ccee30932b8aab4cb97.zip cpython-18aef3c10214fba136da7ccee30932b8aab4cb97.tar.gz cpython-18aef3c10214fba136da7ccee30932b8aab4cb97.tar.bz2 |
Support disassembly of a variety of objects through dis.dis().
-rw-r--r-- | Lib/dis.py | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -2,10 +2,27 @@ import sys import string +import types def dis(x=None): if not x: distb() + return + if type(x) is types.InstanceType: + x = x.__class__ + if hasattr(x, '__dict__'): + items = x.__dict__.items() + items.sort() + for name, x1 in items: + if type(x1) in (types.MethodType, + types.FunctionType, + types.CodeType): + print "Disassembly of %s:" % name + try: + dis(x1) + except TypeError, msg: + print "Sorry:", msg + print else: if hasattr(x, 'im_func'): x = x.im_func |