Show More
@@ -2364,9 +2364,9 class InteractiveShell(SingletonConfigurable): | |||
|
2364 | 2364 | result = fn(*args, **kwargs) |
|
2365 | 2365 | |
|
2366 | 2366 | # The code below prevents the output from being displayed |
|
2367 |
# when using magics with decodator @output_can_be_ |
|
|
2367 | # when using magics with decodator @output_can_be_silenced | |
|
2368 | 2368 | # when the last Python token in the expression is a ';'. |
|
2369 |
if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_ |
|
|
2369 | if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False): | |
|
2370 | 2370 | if DisplayHook.semicolon_at_end_of_expression(magic_arg_s): |
|
2371 | 2371 | return None |
|
2372 | 2372 |
@@ -258,7 +258,7 def _function_magic_marker(magic_kind): | |||
|
258 | 258 | |
|
259 | 259 | |
|
260 | 260 | MAGIC_NO_VAR_EXPAND_ATTR = "_ipython_magic_no_var_expand" |
|
261 |
MAGIC_OUTPUT_CAN_BE_ |
|
|
261 | MAGIC_OUTPUT_CAN_BE_SILENCED = "_ipython_magic_output_can_be_silenced" | |
|
262 | 262 | |
|
263 | 263 | |
|
264 | 264 | def no_var_expand(magic_func): |
@@ -277,14 +277,14 def no_var_expand(magic_func): | |||
|
277 | 277 | return magic_func |
|
278 | 278 | |
|
279 | 279 | |
|
280 |
def output_can_be_ |
|
|
281 |
"""Mark a magic function so its output may be |
|
|
280 | def output_can_be_silenced(magic_func): | |
|
281 | """Mark a magic function so its output may be silenced. | |
|
282 | 282 | |
|
283 |
The output is |
|
|
283 | The output is silenced if the Python expression used as a parameter of | |
|
284 | 284 | the magic ends in a semicolon, not counting a Python comment that can |
|
285 |
follow |
|
|
285 | follow it. | |
|
286 | 286 | """ |
|
287 |
setattr(magic_func, MAGIC_OUTPUT_CAN_BE_ |
|
|
287 | setattr(magic_func, MAGIC_OUTPUT_CAN_BE_SILENCED, True) | |
|
288 | 288 | return magic_func |
|
289 | 289 | |
|
290 | 290 | # Create the actual decorators for public use |
@@ -37,7 +37,7 from IPython.core.magic import ( | |||
|
37 | 37 | magics_class, |
|
38 | 38 | needs_local_scope, |
|
39 | 39 | no_var_expand, |
|
40 |
output_can_be_ |
|
|
40 | output_can_be_silenced, | |
|
41 | 41 | on_off, |
|
42 | 42 | ) |
|
43 | 43 | from IPython.testing.skipdoctest import skip_doctest |
@@ -1195,7 +1195,7 class ExecutionMagics(Magics): | |||
|
1195 | 1195 | @no_var_expand |
|
1196 | 1196 | @needs_local_scope |
|
1197 | 1197 | @line_cell_magic |
|
1198 |
@output_can_be_ |
|
|
1198 | @output_can_be_silenced | |
|
1199 | 1199 | def time(self,line='', cell=None, local_ns=None): |
|
1200 | 1200 | """Time execution of a Python statement or expression. |
|
1201 | 1201 |
General Comments 0
You need to be logged in to leave comments.
Login now