Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 3rd, 2012  |  syntax: Python  |  size: 0.24 KB  |  views: 37  |  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