"Ben Sizer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
But you could use a dict of return values, or even just assigning a
different return value in each if clause. The end result is that you
have a single well-defined exit point from the function, which is
generally considered to be preferable.

Preferable, but not any form of an absolute. "Single Exit" was one of the recommendations from the early structured program work back in the 70s, and the industry has long since sent it to the dustbin of history.

The issue is a simple one of clarity, and woodenly applying
the single exit rule where it doesn't belong frequently
winds up creating nested if-elif-else structures and extranious
flag variables.

If an embedded return isn't clear, the method probably
needs to be refactored with "extract method" a few
times until it is clear.

John Roth


-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to