No return to the parent function
arnodel at googlemail.com
Tue Feb 2 17:55:58 CET 2010
Joan Miller <peloko45 at gmail.com> writes:
> I've a main function called i.e. *foo()* which has a block of code
> that is repetead several times (for the error catching code and error
> reporting), but that code has a return to exit of *foo()*
> if self.background:
> return ReturnCode.ERROR, None
> raise NameError(error)
> So I would tu put that code block into a separated function (*throw()
> *), but the problem is that it returns to the parent function (foo()).
> How to solve it?
If I understand correctly, you can simply do this:
I.e. if throw returns something, foo returns it as well. If throw
raises an exception, it will go through foo. Is this what you want?
More information about the Python-list