Greg Ewing <greg.ewing@compaq.com> wrote:
> Not if you go about it the right way. I always
> put such loops in a procedure of their own,
> and use return:
>
> def find_the_holy_grail(stuff):
> for x in stuff:
> if is_holy_grail(x):
> return x
> return None
hey, didn't your MOM tell you to only use a
SINGLE return statement per function, and
put that at the END of the function body? ;-)
> I wouldn't mind if there weren't any break - and
> without break, there would be no need for the
> weird else.
well, I think it's time for a break...
</F>
> Not if you go about it the right way. I always
> put such loops in a procedure of their own,
> and use return:
>
> def find_the_holy_grail(stuff):
> for x in stuff:
> if is_holy_grail(x):
> return x
> return None
hey, didn't your MOM tell you to only use a
SINGLE return statement per function, and
put that at the END of the function body? ;-)
> I wouldn't mind if there weren't any break - and
> without break, there would be no need for the
> weird else.
well, I think it's time for a break...
</F>