import warnings
warnings.filterwarnings("ignore")
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()
# Warnings as errors for all the program
import warnings
warnings.filterwarnings("error")
# Warnings as errors whithin block
import warnings
with warnings.catch_warnings():
warnings.simplefilter("error")
# Code in this block will raise exception for a warning