[Tutor] Re: Catching warnings?

Bill Mill bill.mill at gmail.com
Tue Oct 19 17:09:29 CEST 2004


Liam,

The 'rotor' module is deprecated:

>>> import rotor
__main__:1: DeprecationWarning: the rotor module uses an insecure algorithm and
is deprecated

If we want to ignore the error, we can simply catch it as we do any
other exception:

>>> try:
...     import rotor
... except DeprecationWarning: 
...     pass
...
>>>

Peace
Bill Mill
bill.mill at gmail.com

On Wed, 20 Oct 2004 01:11:59 +1300, Liam Clarke <cyresse at gmail.com> wrote:
> Oops, "Just a quick question, catching errors is easy, but how to go about
> catching errors?"
> 
> I meant, of course, catching warnings.... (it's late,  that's my
> excuse and I'm sticking to it.)
> 
> 
> 
> 
> On Wed, 20 Oct 2004 01:10:00 +1300, Liam Clarke <cyresse at gmail.com> wrote:
> > Hi all,
> >
> > Just a quick question, catching errors is easy, but how to go about
> > catching errors? I'd like to squelch a deprecation warning. I know the
> > module's deprecated, but it's useful for the moment.
> >
> > So far I've filtered it with Warnings.filterwarnings, but the docs
> > state that warning are technically exceptions. Can you catch them the
> > same way you can catch error codes?
> >
> > Oh, and personally, I think I just met the most subtle way of saying
> > 'You're missing a closed bracket' -
> >
> > Token Error: EOF in multi-line statement
> >
> > Grrrr
> >
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list