[Python-ideas] Show deprecation warnings in the interactive interpreter
Ezio Melotti
ezio.melotti at gmail.com
Thu Feb 26 00:56:33 CET 2015
Hi,
On Wed, Feb 25, 2015 at 9:51 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> What you are think about turning deprecation warnings on by default in the
> interactive interpreter?
>
+1
If I'm using the interpreter to try some piece of code I'm not
familiar with, I would rather get a warning immediately and proceed to
find the right solution, rather than spending time figuring out how
some deprecated function works, use it in my application, write the
tests for it, and only then find out that I've been wasting my time
with something that was deprecated (or worse, find it out once I
update Python and the function is no longer there).
Using flags (both existing and new proposed ones) to enable warnings
has three issues:
1) you have to know that deprecation warnings are silenced by
default and that there is an option to enable them;
2) you have to remember the flag/syntax to enable them;
3) you have to do it every time you start the interpreter;
Realistically I don't see people starting using "python3 --some-flag"
regularly just to see all the warnings.
Regarding deprecation warnings raised while importing 3rd party code:
1) most of the time there's very little code executed at import time
(mostly function/classes definitions), so the chance of getting
warnings should be quite low;
2) if there are warnings (e.g. because the module I'm importing
imports some deprecated module), I can either report them upstream or
simply dismiss them. Seeing that there are warnings might also make
me reconsider the use of the module (since it might not work on more
recent Pythons, or might even have security implications).
Best Regards,
Ezio Melotti
> Deprecation warnings are silent by default because they just annoys end user
> that uses old Python program with new Python. End user usually is not a
> programmer and can't do something with warnings. But in the interactive
> interpreter the user is the author of executed code and can avoid to use
> deprecated functions if warned.
>
More information about the Python-ideas
mailing list