Skip to content

Instantly share code, notes, and snippets.

@Newlifer
Created April 6, 2016 10:00
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 Newlifer/2c9918456c8a713fd95bdadacd714128 to your computer and use it in GitHub Desktop.
Save Newlifer/2c9918456c8a713fd95bdadacd714128 to your computer and use it in GitHub Desktop.
class Value (Exception):
def __init__ (self, vl):
self._vl = vl
def __int__ (self):
return self._vl
def add (a, b):
raise Value(a + b)
def mul (a, b):
raise Value(a * b)
a = 2
b = 2
try:
add (a, b)
except Value as rs:
try:
mul (int(rs), b)
except Value as rs2:
print (int (rs2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment