[Tutor] raise exception works as planned in program but not when imported into testing module

Jim Mooney Py3.4.3winXP cybervigilante at gmail.com
Thu Apr 30 09:08:04 CEST 2015


Oops, my mistake. Ignore dumb remark below.  I was thinking of the try -
except in the main loop, but since I only tested the parse function, I
never used that. I need to look a bit harder and find this stuff Before I
post ;')

Jim

On 29 April 2015 at 23:04, Jim Mooney Py3.4.3winXP <cybervigilante at gmail.com
> wrote:

>
> I think I meant something like this. An exception in a function is caught
> by the caller. I imported the program that did this into the test program,
> expecting the exception to still be caught when the parse_string was
> called, by the try except else block in the mainroutine of the imported
> program..
>
> def excepter():
>     raise ValueError
>
> try:
>     excepter()
> except ValueError:
>     print("Exception caught after function call")
>
> REPL
> >>>
> Exception caught after function call
>




-- 
Jim

"What a rotten, failed experiment. I'll start over. Maybe dogs instead of
monkeys this time." --God


More information about the Tutor mailing list