I was looking at the documentation for try except and the built in values listed there, but I figure out what I should be using to catch a general function fail. here's what I mean say I have these: foo.py
def create_apples(x,y,z):
appleMaker = appleMaker()
appleMaker.maker(x,y,z)
def create_bananas(x,y,z):
bananaMaker = BananaMaker()
bananaMaker.maker(x,y,z)
if __name__ == '__main__':
x = 1
y = 2
z = 3
create_apples(x, y, z)
create_bananas(x, y, z)
with appleMaker.py:
from random import randint
class appleMaker:
def __init__(self):
self.bushelID
self.numberCreated
def maker(x, y, z):
self.bushelID = randint(0,9)
self.numberCreated = x + y + z
and BananaMaker.py looking exactly the same as appleMaker.py respectively. What I want to be able to do is in foo, something like:
try:
create_apple(x,y,z)
except Exception:
print "informative information"
sys.exit(1)