else clauses in while and for loops

Chuck Esterbrook echuck at mindspring.com
Sun Apr 16 21:00:18 EDT 2000


Jonathan Giddy wrote:

> Chuck Esterbrook declared:
> >
> >On another topic: With regards to the "try...except" technique above
> >(which I've seen quite a bit in Python) does the following code do the
> >same thing and if so, which do you find more readable?
>
> It does do the same thing with the extra line included below.  Now that
> I've looked at this code in more detail than usual, I would probably choose
> your form over my original, mainly on the grounds that it's quite likely
> for the test to fail, so it's not really "exceptional" behaviour.
>
> However, for code that is executed once over a limited number of
> iterations, I'm not losing sleep either way.

Agreed. I just wanted to know about the two styles in general.

Thanks,

-Chuck


More information about the Python-list mailing list