[Tutor] Re: Catching warnings?

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Oct 20 03:20:30 CEST 2004



On Tue, 19 Oct 2004, Bill Mill wrote:

> 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
> ...
> >>>


As a warning, when something's labeled as "deprecated" in Python, the
implementors really mean it: 'rotor' is gone in the upcoming Python 2.4
release.

So, unless there's an overriding reason, don't ignore DeprecationWarnings,
because there is a strong chance that code that uses a deprecated feature
won't work in the future.  Warnings are there for a reason!  *grin*



More information about the Tutor mailing list