Surpressing Warnings

Chris Rebert clp2 at rebertia.com
Mon Aug 10 00:47:58 CEST 2009


On Sun, Aug 9, 2009 at 4:21 PM, Victor Subervi<victorsubervi at gmail.com> wrote:
> Hi:
> I get a ton of warnings like this from a program I run:
>
> Warning (from warnings module):
>   File "C:\Python25\read.py", line 67
>     cursor.execute(sqlKWDrop)
> Warning: Unknown table 'judaism_128'
>
> How do I surpress them?

import warnings
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    cursor.execute(sqlKWDrop)
#repeat for every call that's causing warnings

or to just silence all warnings from anywhere:

import warnings
warnings.simplefilter("ignore")

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list