Skip to content

Instantly share code, notes, and snippets.

@icio
Created July 23, 2012 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icio/3166670 to your computer and use it in GitHub Desktop.
Save icio/3166670 to your computer and use it in GitHub Desktop.
Python for/else
# For and if
for module in self.modules.values():
ok = True
for f in filters:
if not f(module):
ok = False
break
if ok:
yield module
# For..else
for module in self.modules.values():
for f in filters:
if not f(module):
break
else:
yield module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment