Created
July 23, 2012 22:33
-
-
Save icio/3166670 to your computer and use it in GitHub Desktop.
Python for/else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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