logging with exception and warning handling

Manage warnings

Warning catagory (class) Description
Warning This is the base class of all warning category classes. It is a subclass of Exception.
UserWarning The default category for warn().
DeprecationWarning Base category for warnings about deprecated features.
SyntaxWarning Base category for warnings about dubious syntactic features.
RuntimeWarning Base category for warnings about dubious runtime features.
FutureWarning Base category for warnings about constructs that will change semantically in the future

https://docs.python.org/2.4/lib/warning-categories.html

User code can define additional warning categories by subclassing one of the standard warning categories. A warning category must always be a subclass of the Warning class.

def supress_warnings(categories=[]):
  "Supress python warnings either all [] or specific `catagories` of warning"
  import warnings
  if cats == []: warnings.filterwarnings("ignore")
  else:
    for cat in categories:
      warnings.filterwarnings(action="ignore", category=cat)

supress_warnings[source]

supress_warnings(categories=[])

Supress python warnings either all [] or specific catagories of warning