Last active
January 12, 2019 13:09
-
-
Save mutoo/b84af24688377d857f4aaede8bfefa6c to your computer and use it in GitHub Desktop.
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
# define an exception for flow control | |
class ELSE(Exception): pass | |
# since we cannot write: `condition or raise ELSE()` => (syntax error) | |
# we need to define a func to raise an exception | |
def THEN(): | |
raise ELSE() | |
# define our IF to make it looks intuitive | |
def IF(condition): | |
return condition | |
# A simple sample | |
A = 10 | |
try: | |
IF(A > 10) or THEN() | |
print("A is > 10") | |
except ELSE: | |
print("A is <= 10") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment