Re: [Tutor] Exception Handling and Stack traces

2010-09-11 Thread Steven D'Aprano
On Sat, 11 Sep 2010 04:47:13 am Michael Powe wrote: > No problem, I am working on getting this sorted out. The > documentation seems to be written as reminder for people who already > know how this stuff works, rather than as a clear explanation for > anybody working with it. That's because the

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 04:42:35PM +0200, Peter Otten wrote: > Michael Powe wrote: > > On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > >> Michael Powe wrote: > >> > I can't work out how to suppress stacktrace printing when exceptions > >> > are thrown. > >> WRONG: > >> > >> >>>

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Peter Otten
Michael Powe wrote: > On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: >> Michael Powe wrote: >> >> > I can't work out how to suppress stacktrace printing when exceptions >> > are thrown. >> >> [snip rant] >> >> It might have been a good idea to read a tutorial like >> >> http://do

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 03:50:57PM +0200, Evert Rol wrote: > This is a bit of a guess, but as far as I know, you can catch exceptions like > that. > Try: > try: > data = opener.open(url) > except urllib2.URLError as msg: > print msg > sys.exit(1) > If you're using an older versio

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Evert Rol
>>> I can't work out how to suppress stacktrace printing when exceptions >>> are thrown. >> >> [snip rant] >> >> It might have been a good idea to read a tutorial like >> >> http://docs.python.org/tutorial/errors.html#handling-exceptions > >> or ask before you got annoyed enough to write that r

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
On Fri, Sep 10, 2010 at 03:56:51PM +0200, Peter Otten wrote: > Michael Powe wrote: > > > I can't work out how to suppress stacktrace printing when exceptions > > are thrown. > > [snip rant] > > It might have been a good idea to read a tutorial like > > http://docs.python.org/tutorial/errors.htm

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Peter Otten
Michael Powe wrote: > I can't work out how to suppress stacktrace printing when exceptions > are thrown. [snip rant] It might have been a good idea to read a tutorial like http://docs.python.org/tutorial/errors.html#handling-exceptions or ask before you got annoyed enough to write that rant ;)

Re: [Tutor] Exception Handling and Stack traces

2010-09-10 Thread Evert Rol
> I can't work out how to suppress stacktrace printing when exceptions > are thrown. > > I want the thrown exception to pass a message on the console, just > like Java does when I catch an exception and print e.getMessage(). > > I tried some of the examples of controlling traceback through the >

[Tutor] Exception Handling and Stack traces

2010-09-10 Thread Michael Powe
Hello, I can't work out how to suppress stacktrace printing when exceptions are thrown. I want the thrown exception to pass a message on the console, just like Java does when I catch an exception and print e.getMessage(). I tried some of the examples of controlling traceback through the tracebac