]> granicus.if.org Git - python/commitdiff
factor out constant
authorBenjamin Peterson <benjamin@python.org>
Sun, 4 Apr 2010 23:26:50 +0000 (23:26 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 4 Apr 2010 23:26:50 +0000 (23:26 +0000)
Lib/dis.py

index 2b400dc88f9e784c3785982955b65c845dd0687f..2c4e82821a84ac98af9bb31e6f225580e41093ab 100644 (file)
@@ -10,6 +10,8 @@ __all__ = ["dis", "disassemble", "distb", "disco",
            "findlinestarts", "findlabels"] + _opcodes_all
 del _opcodes_all
 
+_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
+
 def dis(x=None):
     """Disassemble classes, methods, functions, or code.
 
@@ -26,8 +28,7 @@ def dis(x=None):
     if hasattr(x, '__dict__'):
         items = sorted(x.__dict__.items())
         for name, x1 in items:
-            if isinstance(x1, (types.MethodType, types.FunctionType,
-                               types.CodeType, type)):
+            if isinstance(x1, _have_code):
                 print("Disassembly of %s:" % name)
                 try:
                     dis(x1)