[Tutor] Multiple exits in a function...
Chris Cioffi
other at stopthesanity.org
Fri Oct 24 21:18:43 EDT 2003
Um, when a test fails and you need to 'get out of dodge' there are these
things called exceptions. Python's are rather nice. :)
OTOH, as long as the code is clear I don't think it's _necessarily_ bad
style to use multiple exit points. My only advise in those cases: Be
Obvious(tm) . Nothing is worse than wading through a bunch of code only
to find that it is never reached.
Chris
Mike Hansen wrote:
> I'm curious about this. A co-worker was ranting recently while
> debugging some C code that it had multiple exits. (BTW: It wasn't my
> C code. I have never written C code except in college.)
>
> I trend to write my functions with multiple exits. Usually when some
> test fails, I spit a message(email, print it, or write it to a log
> file) and get out of dodge. The alternative is usually horrible
> nested If statements even if I flip the logic around. Which to me
> makes it hard to read and maintain.
>
> Can you point me to some resources to help me wrap my mind around
> this? Code examples? ...
>
> Thanks,
>
> Mike
>
More information about the Tutor
mailing list