On Tue, Apr 25, 2006 at 10:32:35PM +0200, Bram Moolenaar wrote:

> This for loop is like it is in Python, and it has proven to be very
> useful.
> 
> It's easy to add something to the list if you want to loop over more
> things.  E.g.:
> 
>        for home in split(&rtp,',') + ['']
>          if isdirectory(home) | break | endif
>        endfor

One relevant difference is that Python's for has an else clause:

  for x in list:
    if some_condition:
      break
  else:
    # this executes only if the loop completed without a break
    do_something

It's strange to use 'else' for this, but it does fill a need.

Reply via email to