[BangPypers] suppressing the exception stack trace

Noufal Ibrahim noufal at gmail.com
Tue Sep 15 17:35:54 CEST 2009

On Tue, Sep 15, 2009 at 8:56 PM, Vishal <vsapre80 at gmail.com> wrote:
> Hello,
> I would like to raise an exception of type Exception(), however the regular
> exception stack trace needs to be supressed.
> This is needed in a function that takes raw_input() from the user and based
> on 'Y' or 'N', the function suspends further execution and returns to the
> python prompt or continues. An exit() brings it out of the python
> process....where as what is needed is coming back to the python prompt.

If you want to embed the interactive interpreter at any point in your
program, you can do this

import code

> I want a custom message to appear instead of a regular exception stack trace
> message.

I'm not sure I understand. How is this related to your original question?
In any case, you want to catch exceptions and do something, the patter
is something like this

  # Your code
except Exception,m:
  # Your custom message and action


More information about the BangPypers mailing list