def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
    'Get full tracebacks when warning is raised by setting\n\n    warnings.showwarning = warn_with_traceback\n\n    See also\n    --------\n    http://stackoverflow.com/questions/22373927/get-traceback-of-warnings\n    '
    import traceback
    traceback.print_stack()
    log = (file if hasattr(file, 'write') else sys.stderr)
    settings.write(warnings.formatwarning(message, category, filename, lineno, line))
Get full tracebacks when warning is raised by setting

warnings.showwarning = warn_with_traceback

See also
--------
http://stackoverflow.com/questions/22373927/get-traceback-of-warnings
def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
    'Get full tracebacks when warning is raised by setting\n\n    warnings.showwarning = warn_with_traceback\n\n    See also\n    --------\n    http://stackoverflow.com/questions/22373927/get-traceback-of-warnings\n    '
    import traceback
    traceback.print_stack()
    log = (file if hasattr(file, 'write') else sys.stderr)
    settings.write(warnings.formatwarning(message, category, filename, lineno, line))