[Tutor] Stack unwind using exceptions.
bob gailer
bgailer at gmail.com
Sun Jul 5 19:59:08 CEST 2009
Noufal Ibrahim wrote:
> Kent Johnson wrote:
> [..]
>> Why not just return the value from the function and pass it up the
>> call chain? If a call fails return None. Something like this:
>
> That's what I ended up doing but the first thing occurred to me and I
> was just wondering if there's any production code that relies on the
> technique.
>
I use the exception technique in my Python Pipelines parser. The
recursive routine has 6 raise statements. The exceptions are caught by
the program that calls the recursive routine. There would be more code
and complexity to work back up the call chain.
--
Bob Gailer
Chapel Hill NC
919-636-4239
More information about the Tutor
mailing list