On Sep 27, 2006, at 12:57 PM, Russell Campbell wrote:
One more question: Would Python figure out an error in the code
below?
DO LOOP CONSTRUCT
Code Line 1 && Supposed to be in the loop
Code Line 2 && Supposed to be in the loop
Code Line 3 && Supposed to be in the loop
Code Line 4 && ALSO supposed to be in the loop!!!!!!!!
Code Line 5 && Not supposed to be in the loop.
Code Line 6 && Not supposed to be in the loop.
Code Line 4 is the problem. How would Python catch it? Does it
require, as
I alluded to in a previous post, a blank line to end the loop code? I
started thinking that was the case, which would be a better design,
but
still not one I'm sold on.
No, it would not catch that, as there is nothing to catch. You've
told the compiler that the loop structure has ended by outdenting,
just as if you were to write in VFP:
DO LOOP CONSTRUCT
Code Line 1 && Supposed to be in the loop
Code Line 2 && Supposed to be in the loop
Code Line 3 && Supposed to be in the loop
ENDDO
Code Line 4 && ALSO supposed to be in the loop!!!!!!!!
Code Line 5 && Not supposed to be in the loop.
Code Line 6 && Not supposed to be in the loop.
The 'ENDDO' is the closure of the block. Looking at the code there
is no way for you to determine, unless you know what Line 4 is
supposed to be doing, that there is an error here. The same is true
in Python: if you are sloppy and place a statement outside of the
loop structure, it won't get looped.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.