Created
July 3, 2014 17:24
-
-
Save hexsprite/06d5c5cd13cbcae4ba24 to your computer and use it in GitHub Desktop.
Python: ignore specific warning using context manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
def fxn(): | |
warnings.warn("deprecated", DeprecationWarning) | |
with warnings.catch_warnings(): | |
warnings.filterwarnings('ignore', category=DeprecationWarning) | |
fxn() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment