** Pastebin PRO Accounts Spring Special ** Get 40% discount for a limited time only! Click Here to check it out ;-)Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Nov 3rd, 2012  |  syntax: Python  |  size: 0.24 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def default(defaultval, f, allowNone=False, *args, **kwargs):
  2.     try:
  3.         ret = f(*args, **kwargs)
  4.         if ret is None and not allowNone:
  5.             return defaultval
  6.     except Exception as e:
  7.         return defaultval
  8.     return ret
clone this paste RAW Paste Data