Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e6c6ac

Browse files
committed
#18796: improve documentation of the file argument of dis.show_code. Initial patch by Vajrasky Kok.
1 parent f79126f commit 6e6c6ac

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Doc/library/dis.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ object isn't useful:
109109
.. function:: show_code(x, *, file=None)
110110

111111
Print detailed code object information for the supplied function, method,
112-
source code string or code object to stdout.
112+
source code string or code object to *file* (or ``sys.stdout`` if *file*
113+
is not specified).
113114

114115
This is a convenient shorthand for ``print(code_info(x), file=file)``,
115116
intended for interactive exploration at the interpreter prompt.

Lib/dis.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ def _format_code_info(co):
146146
return "\n".join(lines)
147147

148148
def show_code(co, *, file=None):
149-
"""Print details of methods, functions, or code to stdout."""
149+
"""Print details of methods, functions, or code to *file*.
150+
151+
If *file* is not provided, the output is printed on stdout.
152+
"""
150153
print(code_info(co), file=file)
151154

152155
_Instruction = collections.namedtuple("_Instruction",

0 commit comments

Comments
 (0)