Created
March 18, 2016 17:31
-
-
Save msikma/4a78e21c7844f2bf33ae 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
next_item = Word() | |
# next_item is either a Word object, which has .is_type(), or it's None | |
if next_item is None: | |
# code for situation A | |
elif next_item.is_type('something'): | |
# code for situation B | |
elif next_item.is_type('something_else'): | |
# code for situation C | |
else: | |
# code for situation A | |
# is there any way I can neatly combine the two situation A? | |
# I don't want to repeat myself. if I put the 'is None' statement below, it will raise an AttributeError on None. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment