summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-08-23 22:41:39 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2013-08-23 22:41:39 +0300
commit95a966471e88133d1b21601388dc8405c5bd5fcd (patch)
tree3049bf9203beb3ffb8236af3418ac63b889cbb20
parentc162cbbc55c26fbbdd8903665a69b022aac7976a (diff)
downloadcpython-95a966471e88133d1b21601388dc8405c5bd5fcd.tar.gz
#18796: improve documentation of the file argument of dis.show_code. Initial patch by Vajrasky Kok.
-rw-r--r--Doc/library/dis.rst3
-rw-r--r--Lib/dis.py5
2 files changed, 6 insertions, 2 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 468ce92cf1..a546f68df0 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -109,7 +109,8 @@ object isn't useful:
.. function:: show_code(x, *, file=None)
Print detailed code object information for the supplied function, method,
- source code string or code object to stdout.
+ source code string or code object to *file* (or ``sys.stdout`` if *file*
+ is not specified).
This is a convenient shorthand for ``print(code_info(x), file=file)``,
intended for interactive exploration at the interpreter prompt.
diff --git a/Lib/dis.py b/Lib/dis.py
index ca4094c1bb..0d62c0828c 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -146,7 +146,10 @@ def _format_code_info(co):
return "\n".join(lines)
def show_code(co, *, file=None):
- """Print details of methods, functions, or code to stdout."""
+ """Print details of methods, functions, or code to *file*.
+
+ If *file* is not provided, the output is printed on stdout.
+ """
print(code_info(co), file=file)
_Instruction = collections.namedtuple("_Instruction",