So I solved my own problem. I was running my own __init__ function in the 
Class (I didn't put that in the post because I didn't see it as relevant... 
it was)  I had to do the instructions further down the page to use my own 
init function.  Hopefully if someone else runs into this, this post can 
help them. *Self High Five

John


On Monday, June 19, 2017 at 11:30:56 AM UTC-5, John Omernik 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/ca84ab0b-c699-4b4d-9e70-e92dc3cf43f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to