[Python-Dev] Re: A warning switch?

Guido van Rossum guido@python.org
Mon, 28 Feb 2000 12:35:12 -0500


> Fredrik Lundh writes ( about .append(x,y) ):
> >I suggest adding an explicit warning in the 1.6 docs,
> >and removing it in the first post-1.6 release.
> 
> What about adding a command-line switch for enabling warnings, as has
> been suggested long ago?  The .append() change could then print a
> warning in 1.6alphas (and betas?), but still run, and be turned into
> an error later.

That's better.  I propose that the warnings are normally on, and that
there are flags to turn them off or thrn them into errors.
Alternatively, the default should be warnings == errors, with flags to
turn them into warnings or turn them off.  Turning them off by default
seems to defeat the purpose -- only the most zealous will use them.

The warning messages should show a source file and line number and
display the source code line if available, just like in a traceback;
but no traceback info should be printed.  Also, a warning should only
be printed once per message/file/lineno combination, per Python
invocation.  A dictionary could take care of this.

Anybody care to further specify and then code up such a mechanism?

--Guido van Rossum (home page: http://www.python.org/~guido/)