[Python-ideas] Add 'use warnings' directive, like in Perl
Geoffrey Spear
geoffspear at gmail.com
Tue Feb 10 17:40:22 CET 2015
On Tue, Feb 10, 2015 at 11:26 AM, Ian Cordasco <graffatcolmingov at gmail.com>
wrote:
>
>
> $ python test.py
>
> Would first result in a SyntaxError (because of your else following
> the first else) and then once that's been fixed, you'd get a
> NameError.
>
> Disclaimer: I didn't actually run the code so I may have the order of
> errors wrong, but I think this is roughly correct.
>
>
The syntax error can be corrected with elif, but the OP is correct that the
NameError will only happen when that branch is actually run, not at
compile-time.
Of course, this is probably a better argument for a test suite that covers
all of your branches and doing static analysis than it is for adding
Perl-style pragmas to the language. Perl needed use warnings and use strict
because the language allows some horrible things and didn't want to make
good programming mandatory at the expense of breaking existing code,
instead making it "suggested" to use pragmas that enforce some good habits.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150210/06c8058f/attachment.html>
More information about the Python-ideas
mailing list