[IPython-user] Using IPShellEmbed

Fernando Perez fperez.net@gmail....
Sun Mar 18 23:04:22 CDT 2007


On 10/12/06, Frédéric Mantegazza <mantegazza@ill.fr> wrote:
> Le jeudi 12 octobre 2006 08:57, Fernando Perez a écrit :
>
> > Yes, it allows you to set the user's local namespace.  The fact that
> > %who doesn't list its contents is an unfortunate implementation
> > artifact: when the shell starts, it first scans the contents of
> > user_ns and hides those keys from display with %who, so that anything
> > that got loaded before startup isn't shown, and you only see things
> > you actually created interactively.  That decision seemed like a good
> > policy when I wrote %who years ago (and ipshellembed didn't exist),
> > but it may not be such a good one in this context.  I'm not even 100%
> > sure it was such a good idea in the first place :)
>
> In fact, this is OK for me too! Don't change anything for me! It allows me
> to hide some objects from user. This way, only advanced users can access to
> these objects :o)
>
> I have another question: I execute some code inside IPShellEmbed with
> IP.runlines() method. Is there a way to catch exceptions and avoid the code
> to stop? I implemented a custom exception handler, with the
> IP.set_custom_exc() method, but I don't know how to tell the shell to
> continue the execution (under some conditions).
>
> Is it possible ?

I don't think it is, at least not easily: python doesn't have the
notion of 'resumable exceptions', so there's nothing at the language
level that allows an exception handler to restart execution.

regards,

f


More information about the IPython-user mailing list