1.5.2 or: else:

Fredrik Lundh fredrik at pythonware.com
Wed Jul 28 17:36:22 EDT 1999


Greg Ewing <greg.ewing at 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>





More information about the Python-list mailing list