<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| So far in Python I've almost hated the 'else' of the 'for' loops:
| - I have problems to remember its meaning;

Consider the following pseudoPython which you should understand:

label: loop
if cond:
   do_something()
   goto loop
else:
  do_else()

We actually write the above as

while cond:
  do_something()
else:
  do_else()

Same meaning; do_else is executed when condition is false.

A for-loop is equivalent to a while loop with the condition 'iterator is 
not exhausted'.  So do_else when that condition is false -- the iterator is 
exhausted.

Terry Jan Reedy



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

Reply via email to