[Python-checkins] r84672 - in python/branches/py3k: Doc/library/dis.rst Lib/dis.py

nick.coghlan python-checkins at python.org
Fri Sep 10 16:08:05 CEST 2010


Author: nick.coghlan
Date: Fri Sep 10 16:08:04 2010
New Revision: 84672

Log:
As per python-dev discussion with Eli, properly document and publish dis.show_code

Modified:
   python/branches/py3k/Doc/library/dis.rst
   python/branches/py3k/Lib/dis.py

Modified: python/branches/py3k/Doc/library/dis.rst
==============================================================================
--- python/branches/py3k/Doc/library/dis.rst	(original)
+++ python/branches/py3k/Doc/library/dis.rst	Fri Sep 10 16:08:04 2010
@@ -36,7 +36,7 @@
 The :mod:`dis` module defines the following functions and constants:
 
 
-.. function:: code_info(x=None)
+.. function:: code_info(x)
 
    Return a formatted multi-line string with detailed code object information
    for the supplied function, method, source code string or code object.
@@ -48,6 +48,16 @@
    .. versionadded:: 3.2
 
 
+.. function:: show_code(x)
+
+   Print detailed code object information for the supplied function, method,
+   source code string or code object to stdout.
+
+   This is a convenient shorthand for ``print(code_info(x))``, intended for
+   interactive exploration at the interpreter prompt.
+
+   .. versionadded:: 3.2
+
 .. function:: dis(x=None)
 
    Disassemble the *x* object.  *x* can denote either a module, a class, a

Modified: python/branches/py3k/Lib/dis.py
==============================================================================
--- python/branches/py3k/Lib/dis.py	(original)
+++ python/branches/py3k/Lib/dis.py	Fri Sep 10 16:08:04 2010
@@ -7,7 +7,7 @@
 from opcode import __all__ as _opcodes_all
 
 __all__ = ["code_info", "dis", "disassemble", "distb", "disco",
-           "findlinestarts", "findlabels"] + _opcodes_all
+           "findlinestarts", "findlabels", "show_code"] + _opcodes_all
 del _opcodes_all
 
 _have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
@@ -140,12 +140,8 @@
             lines.append("%4d: %s" % i_n)
     return "\n".join(lines)
 
-# show_code is deliberately undocumented and left out of __all__,
-# since it doesn't offer any real benefit over code_info() above
-# It is only retained because it already existed and was not
-# marked as private in previous versions of Python
 def show_code(co):
-    """Show details about a code object."""
+    """Print details of methods, functions, or code to stdout."""
     print(code_info(co))
 
 def disassemble(co, lasti=-1):


More information about the Python-checkins mailing list