Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I may be missing something... but how is that clearer than

  for item in report():
      for event in item['events']:
          if event in events_we_care_about:
              act_upon(event)
              break


It's a trivial example. Just to demonstrate how for else helps to control an outer loop from within an inner loop.


Your act_upon is passed values from the inner loop. GP's act_upon is passed values from the outer loop.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: