Hello John, That is really strange, have you tried restarting your kernel? If you make modification to your module it might not be reloaded. Doing exactly what you describe works here (screenshot attached).
Cheers, -- Matthias On Mon, Jun 19, 2017 at 9:30 AM, John Omernik <[email protected]> wrote: > I have been trying to run a Magics Class based on > http://ipython.readthedocs.io/en/stable/config/custommagics.html > > I keep getting an error related to a type error but can't figure out where I > am going, it should simply print the line from the magic, but instead > TypeError. Any help would be appreciated! > > > > Module I load > > from IPython.core.magic import (Magics, magics_class, line_magic, > cell_magic, line_cell_magic) > > @magics_class > class MyClass(Magics): > > @line_magic > def lmagic(self, line): > print(line) > return line > > > > In my IPython Notebook I start things by doing > > ip = get_ipython() > > ip.register_magics(MyClass) > > Then I go to the next cell and type > > %lmagic Hello > > and get: > > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-3-2a6ddce5521d> in <module>() > ----> 1 get_ipython().magic('lmagic Hello') > > /opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in > magic(self, arg_s) > 2156 magic_name, _, magic_arg_s = arg_s.partition(' ') > 2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) > -> 2158 return self.run_line_magic(magic_name, magic_arg_s) > 2159 > 2160 > #------------------------------------------------------------------------- > > /opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in > run_line_magic(self, magic_name, line) > 2077 kwargs['local_ns'] = > sys._getframe(stack_depth).f_locals > 2078 with self.builtin_trap: > -> 2079 result = fn(*args,**kwargs) > 2080 return result > 2081 > > TypeError: 'str' object is not callable > > > > I am stumped on how this is working... > > -- > You received this message because you are subscribed to the Google Groups > "Project Jupyter" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jupyter/9d331991-775a-4032-ad28-36808b71a455%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CANJQusXH6vSBK_dwNFYju87w3k66o8swxdEWe6GCxw2GyrkS%3DA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
