[IPython-User] notebook magic development questions

Ben Mabey ben@benmabey....
Mon Jan 21 10:36:49 CST 2013


On 1/21/13 7:48 AM, Matthias BUSSONNIER wrote:
> Le 21 janv. 2013 à 14:12, Ben Mabey a écrit :
>
>> On 1/20/13 11:16 PM, Matthias BUSSONNIER wrote:
>>> Le 21 janv. 2013 à 06:54, Ben Mabey a écrit :
>>> Hi,
>>>
>>> have you try adding an unload capability ?
>>> http://ipython.org/ipython-doc/dev/config/extensions/index.html#writing-extensions
>>>
>>> There might be some case where you can't unload, but at least you should only have to
>>> restart the current kernel and not the server (from the notebook menu).
>> For simple extensions do I need to unregister the magic to allow for
>> reloading of the code?
>> This is my simple magic so far dealing with ODBC DB connections:
>>
>> https://gist.github.com/4585890
>>
>> In my notebook I am using "%load_ext autoreload" and "%autoreload 2" but
>> changes to the extension don't take effect until after I restart the
>> kernel.  I have tried reevaluating "%load_ext sqlmagic" but that doesn't
>> help either.  Does the extension need to be placed in a certain dir to
>> allow for autoreloading?
> This is not the part of the code where I'm comfortable with,
> but I'm not sure auto reload is made to auto reload magic, but more to reload
> normal modules.
>
> and IIRC, %load_ext does track wether an extension has been loaded and avoid
> loading it if it has not been unloaded.
> Can you try if %reload_ext  works ?

Ah, I didn't know about $reload_ext.  That works and that is much better 
than restarting the kernel. Thanks!
>
> Also, you are welcome to add your extension to
> https://github.com/ipython/ipython/wiki/Extensions-Index
>
> if you wish.
>
I'll add it once I'm happy with it and add some docs.

-Ben


More information about the IPython-User mailing list