pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/ipython/ipython/commit/e0fc2386083aed55b44d4c50661fb53bd4170a3f

aa60c69660fa.css" /> Documentation update · ipython/ipython@e0fc238 · GitHub
Skip to content

Commit e0fc238

Browse files
committed
Documentation update
1 parent 718af29 commit e0fc238

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

IPython/core/magic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def no_var_expand(magic_func):
280280
def output_can_be_silenced(magic_func):
281281
"""Mark a magic function so its output may be silenced.
282282
283-
The output is silenced if the Python expression used as a parameter of
283+
The output is silenced if the Python code used as a parameter of
284284
the magic ends in a semicolon, not counting a Python comment that can
285285
follow it.
286286
"""

docs/source/config/custommagics.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,26 @@ Accessing user namespace and local scope
139139
========================================
140140

141141
When creating line magics, you may need to access surrounding scope to get user
142-
variables (e.g when called inside functions). IPython provide the
142+
variables (e.g when called inside functions). IPython provides the
143143
``@needs_local_scope`` decorator that can be imported from
144144
``IPython.core.magics``. When decorated with ``@needs_local_scope`` a magic will
145145
be passed ``local_ns`` as an argument. As a convenience ``@needs_local_scope``
146146
can also be applied to cell magics even if cell magics cannot appear at local
147147
scope context.
148148

149+
Silencing the magic output
150+
==========================
151+
152+
Sometimes it may be useful to define a magic that can be silenced the same way
153+
that non-magic expressions can, i.e., by appending a semicolon at the end of the Python
154+
code to be executed. That can be achieved by decorating the magic function with
155+
the decorator ``@output_can_be_silenced`` that can be imported from
156+
``IPython.core.magics``. When this decorator is used, IPython will parse the Python
157+
code used by the magic and, if the last token is a ``;``, the output created by the
158+
magic will not show up on the screen. If you want to see an example of this decorator
159+
in action, take a look on the ``time`` magic defined in
160+
``IPython.core.magics.execution.py``.
161+
149162
Complete Example
150163
================
151164

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy