I need some help with a portion of my program I am currently writing. I've been just recently learning Python (2.6) and basically I want my code to check for any exceptions that may have been raised and deal with them. Now I have created some custom exceptions of my own so what I want is for the program to print a certain thing when it sees those exceptions raised, print another thing when it sees ANY other exceptions and continue when no exceptions are raised at all. I am sort of stuck.....What I have so far is this:
try:
'''some code'''
except CustomException1:
return 'blah'
except CustomException2:
return 'meh'
except CustomException3:
return 'wha'
else:
return 'nah'
where else deals with NO raised exceptions. Any ideas?
Question
vladmphoto
Hello all,
I need some help with a portion of my program I am currently writing. I've been just recently learning Python (2.6) and basically I want my code to check for any exceptions that may have been raised and deal with them. Now I have created some custom exceptions of my own so what I want is for the program to print a certain thing when it sees those exceptions raised, print another thing when it sees ANY other exceptions and continue when no exceptions are raised at all. I am sort of stuck.....What I have so far is this:
try:
'''some code'''
except CustomException1:
return 'blah'
except CustomException2:
return 'meh'
except CustomException3:
return 'wha'
else:
return 'nah'
where else deals with NO raised exceptions. Any ideas?
Link to comment
Share on other sites
6 answers to this question
Recommended Posts