[Python-Dev] Catching "return" and "return expr" at compile time

Greg Stein gstein@lyra.org
Wed, 08 Sep 1999 04:53:46 -0700


Greg Ward wrote:
> ...
> > I would suggest sys.warnings be a dictionary.
> >
> > python -Wbad-return -Wlines-per-func=50
> >
> > >>> print sys.warnings
> > {'bad-return': None, 'lines-per-func': '50'}
> 
> Makes sense -- true to warn (possibly giving some extra meaning to
> "truth", as in this example), and false to not warn.  Or maybe None to
> not warn, not-None to warn.  Of course, if there are only compile-time
> warnings, then modifying sys.warnings will only affect future imports,
> execs, evals, etc.

Actually, I had intended *presence* in the dictionary to mean "enabled."
I don't think we'd want to pre-populate the dict with all possible flags
ahead of time, then check for each of them on the command line. (startup
time!) However, if we "simply" parsed the command line, extracted all -W
options and dropped them into the dict, then we're set.

Cheers,
-g

--
Greg Stein, http://www.lyra.org/