@@ -139,13 +139,26 @@ Accessing user namespace and local scope
139139========================================
140140
141141When 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
145145be passed ``local_ns `` as an argument. As a convenience ``@needs_local_scope ``
146146can also be applied to cell magics even if cell magics cannot appear at local
147147scope 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+
149162Complete Example
150163================
151164
0 commit comments