Commit 5a5552d3 authored by Ezio Melotti's avatar Ezio Melotti

#18796: improve documentation of the file argument of dis.show_code. Initial...

#18796: improve documentation of the file argument of dis.show_code.  Initial patch by Vajrasky Kok.
parent 593622d8
...@@ -109,7 +109,8 @@ object isn't useful: ...@@ -109,7 +109,8 @@ object isn't useful:
.. function:: show_code(x, *, file=None) .. function:: show_code(x, *, file=None)
Print detailed code object information for the supplied function, method, 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)``, This is a convenient shorthand for ``print(code_info(x), file=file)``,
intended for interactive exploration at the interpreter prompt. intended for interactive exploration at the interpreter prompt.
......
...@@ -146,7 +146,10 @@ def _format_code_info(co): ...@@ -146,7 +146,10 @@ def _format_code_info(co):
return "\n".join(lines) return "\n".join(lines)
def show_code(co, *, file=None): 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) print(code_info(co), file=file)
_Instruction = collections.namedtuple("_Instruction", _Instruction = collections.namedtuple("_Instruction",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment