Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Ivan Shpotenko
Added: Aug 23, 2017 10:35 AM
Modified: Aug 23, 2017 10:36 AM
Views: 67
Tags: except python try
  1. def try_except(success, failure, *exceptions):
  2.     try:
  3.         return success() if callable(success) else success
  4.     except exceptions or Exception:
  5.         return failure() if callable(failure) else failure
  6.