Skip to content

Instantly share code, notes, and snippets.

@mutoo
Last active January 12, 2019 13:09
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 mutoo/b84af24688377d857f4aaede8bfefa6c to your computer and use it in GitHub Desktop.
Save mutoo/b84af24688377d857f4aaede8bfefa6c to your computer and use it in GitHub Desktop.
# 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