'Python warnings.warn() not returning anything

I'm using warnings.warn(), together with a print, but the warnings are not returned:

if[1!=2]:
    print('Error')
    warnings.warn('Warning!')
#returns:  Error

I'm using Jupyter. Would appreciate if someone could assist



Solution 1:[1]

I was having the same issue. My solution was to switch to python's logging package.

import logging
logging.warning("Warning!")

It printed to the console on my end!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danny Denenberg