turntable/utils.py
def catch(fcn, *args, **kwargs):
    '''try:
          retrun fcn(*args, **kwargs)
       except:
          print traceback
            if 'spit' in kwargs.keys():
                return kwargs['spit']

    Parameters
    ----------
    fcn : function
    *args : unnamed parameters of fcn
    **kwargs : named parameters of fcn
        spit : returns the parameter named return in the exception

    Returns
    -------
    The expected output of fcn or prints the exception traceback

    '''

    try:
        # remove the special kwargs key "spit" and use it to return if it exists
        spit = kwargs.pop('spit')
    except:
        spit = None

    try:
        results = fcn(*args, **kwargs)
        if results:
            return results
    except:
        print traceback.format_exc()
        if spit:
            return spit
def catch(fcn, *args, **kwargs):
    '''try:
          retrun fcn(*args, **kwargs)
       except:
          print traceback
            if 'spit' in kwargs.keys():
                return kwargs['spit']

    Parameters
    ----------
    fcn : function
    *args : unnamed parameters of fcn
    **kwargs : named parameters of fcn
        spit : returns the parameter named return in the exception

    Returns
    -------
    The expected output of fcn or prints the exception traceback

    '''

    try:
        # remove the special kwargs key "spit" and use it to return if it exists
        spit = kwargs.pop('spit')
    except:
        spit = None

    try:
        results = fcn(*args, **kwargs)
        if results:
            return results
    except:
        print traceback.format_exc()
        if spit:
            return spit
try:
          retrun fcn(*args, **kwargs)
       except:
          print traceback
            if 'spit' in kwargs.keys():
                return kwargs['spit']

    Parameters
    ----------
    fcn : function
    *args : unnamed parameters of fcn
    **kwargs : named parameters of fcn
        spit : returns the parameter named return in the exception

    Returns
    -------
    The expected output of fcn or prints the exception traceback