From 03f0a6ce5583399899f379cd034738964d5e09de 2012-06-26 15:46:02 From: Bradley M. Froehle Date: 2012-06-26 15:46:02 Subject: [PATCH] Add %alias_magic examples (t -> timeit, whereami -> pwd). --- diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py index 660e69a..74f073b 100644 --- a/IPython/core/magics/basic.py +++ b/IPython/core/magics/basic.py @@ -59,7 +59,28 @@ class BasicMagics(Magics): ) @line_magic def alias_magic(self, line=''): - """Create an alias for an existing line or cell magic.""" + """Create an alias for an existing line or cell magic. + + Examples + -------- + :: + In [1]: %alias_magic t timeit + + In [2]: %t -n1 pass + 1 loops, best of 3: 954 ns per loop + + In [3]: %%t -n1 + ...: pass + ...: + 1 loops, best of 3: 954 ns per loop + + In [4]: %alias_magic --cell whereami pwd + UsageError: Cell magic function `%%pwd` not found. + In [5]: %alias_magic --line whereami pwd + + In [6]: %whereami + Out[6]: u'/home/testuser' + """ args = magic_arguments.parse_argstring(self.alias_magic, line) shell = self.shell escs = ''.join(magic_escapes.values())