Print only the message on warnings

There is always monkeypatching:

import warnings

def custom_formatwarning(msg, *args, **kwargs):
    # ignore everything except the message
    return str(msg) + '\n'

warnings.formatwarning = custom_formatwarning
warnings.warn("achtung")

Leave a Comment