On Wed, Sep 01, 2021 at 05:27:40PM +1000, Steven D'Aprano wrote:
> Maybe I'm missing something, but I don't think that there is anyway to 
> remove a warning from the warnings filter list so that it will be shown 
> again.
> 
> Example:
> 
>     >>> import warnings
>     >>> warnings.warn("something happened")
>     <stdin>:1: UserWarning: something happened
>     >>> warnings.warn("something happened")
>     >>> 
> 
> Once a warning has been displayed, it won't be displayed again until you 
> exit the interpreter and start a new session. That's usually what we 
> want, but sometimes I do want to re-display the warning.
> 
> The warnings module has a function, reset_warnings, but it does too 
> much, removing all the filters including those set at interpreter 
> startup. I'd like a function to remove a single item, something like 
> this:
> 
>     >>> warnings.warn("something happened")
>     <stdin>:1: UserWarning: something happened
>     >>> warnings.warn("something happened")
>     >>>
>     >>> warnings.forget(UserWarning("something happened"))
>     >>> warnings.warn("something happened")
>     <stdin>:1: UserWarning: something happened
> 
> or similar.
> 
> Thoughts?

Sounds like a missing feature.

Zbyszek
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QDNOEAY5JSGIOLXLUBP2UH2XW5MLSVVX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to