[Python-ideas] Show deprecation warnings in the interactive interpreter
Steven D'Aprano
steve at pearwood.info
Wed Feb 25 10:55:59 CET 2015
On Wed, Feb 25, 2015 at 07:39:50PM +1100, Ben Finney wrote:
> Serhiy Storchaka <storchaka at gmail.com>
> writes:
>
> > What you are think about turning deprecation warnings on by default in
> > the interactive interpreter?
>
> In its favour: Exposing problems early, when they can easily be fixed,
> is good.
>
> To its detriment: Making the interactive interpreter behave differently
> by default from the non-interactive interpreter should be resisted; code
> which behaves a certain way by default in one should behave the same way
> in the other, without extremely compelling justification.
The ship has sailed on that one. In the interactive interpreter:
py> 23 # Evaluating bare objects prints them.
23
py> _
23
py>
But non-interactively:
[steve at ando ~]$ python -c "23
> _"
Traceback (most recent call last):
File "<string>", line 2, in <module>
NameError: name '_' is not defined
I think there are three questions that should be asked:
(1) How does one easy and simply enable warnings in the interactive
interpeter?
(2) If they are enabled by default, how does one easily and simply
disable the again? E.g. from the command line itself, or from your
PYTHONSTARTUP file.
(3) Should they be enabled?
I can't give an opinion on (3) until I know the answer to (1) and (2). I
tried looking at the warnings module and the sys module but nothing
stands out to me.
--
Steve
More information about the Python-ideas
mailing list