python set warning to error code example
Example 1: python suppress warnings in function
import warnings
def fxn():
warnings.warn("deprecated", DeprecationWarning)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fxn()
Example 2: ignoring warnings
import warnings
warnings.filterwarnings(action= 'ignore')