[IPython-User] NameError exception handling during automagic on

Thomas Kluyver takowl@gmail....
Fri Nov 30 14:17:10 CST 2012


Hi Sarvi,

I think your best bet is to set a custom exception handler for NameError.
Have a look at the docstring for
IPython.core.interactiveshell.InteractiveShell.set_custom_exc()

http://ipython.org/ipython-doc/dev/api/generated/IPython.core.interactiveshell.html?highlight=set_custom_exc#IPython.core.interactiveshell.InteractiveShell.set_custom_exc

Best wishes,
Thomas


On 29 November 2012 17:51, Saravanan Shanmugham <sarvilive@gmail.com> wrote:

>
> I am using an embedded ipython shell environnment for a Test Development
> and Execution platform that I am developing.
>
> This includes a set of custom magic commands implemented.
>
> automagic is on.
>
> I would like to change or see a more cleaner error message when I try a
> non-existent magic command without a %
>
> Today I get the following
>  sarvi@cnh-nehalem-103|5> asasdasd
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call last)
> /ws/sarvi-sjc/cisco-vm-tools/scripts/tvt in <module>()
> ----> 1 asasdasd
>
> NameError: name 'asasdasd' is not defined
>
> sarvi@cnh-nehalem-103|6>
>
> I want this custom ipython shell to generate a more clean error message
> without the traceback just like if I had done the following
>
> sarvi@cnh-nehalem-103|6> %asasdasd
> ERROR: Magic function `asasdasd` not found.
> sarvi@cnh-nehalem-103|7>
>
> This mode/capability may not be perfect for python debugging but would be
> great as general purpose shell. When I would like to switch between the
> existing and the new mode though a magic command toggle when needed.
>
> How can I achieve that?
>
> Thanks,
> Sarvi
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20121130/86e39523/attachment-0001.html 


More information about the IPython-User mailing list