Created
July 14, 2009 18:55
-
-
Save apg/147111 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# instead of: | |
match = someregex.match(line) | |
if match: | |
print match.groups() | |
else: | |
print 'boo' | |
# why not make use of the 'as' keyword and do something like: | |
if someregex.match(line) as match: | |
print match.groups() | |
else: | |
print 'boo' | |
# this is a horrible elif example, but similarly, it's just as nice. | |
if someregex.match(line) as match: | |
print match.groups() | |
elif someregex2.match(line) as match: | |
print match.groups() | |
else: | |
print 'boo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment