[Python-3000] removing destructuring del
Neal Norwitz
nnorwitz at gmail.com
Mon Feb 25 06:55:11 CET 2008
On Fri, Feb 22, 2008 at 7:44 AM, Guido van Rossum <guido at python.org> wrote:
[... del (tuple, of, variables), etc deleted]
>
> > I also think
> >
> > del a,
> >
> > should not be legal ("SyntaxError: trailing comma not allowed without
> > surrounding parentheses"?), but that's getting into my own personal
> > preferences.
>
> These all make sense to me, but at the same time it seems such a minor
> issue that I'm not sure we should bother. It would probably end up
> being more custom syntax -- right now it just uses exprlist in the
> grammar and is limited to assignment targets by the compiler.
What bothers me more is assert of a tuple. It does the wrong thing
from what newbies expect. pychecker warns about this, but the version
of pylint in use at Google doesn't warn about this. I wonder if we
should add a warning?
The code I recently saw was:
assert (something_short,
'Some long assertion string that needs its own line')
The original code that pylint warned about was:
assert something_short, \
'Some long assertion string that needs its own line'
Index: Python/compile.c
===================================================================
--- Python/compile.c (revision 61058)
+++ Python/compile.c (working copy)
@@ -2056,6 +2056,9 @@
if (assertion_error == NULL)
return 0;
}
+ if (s->v.Assert.test->kind == Tuple_kind) {
+ printf("got a tuple\n");
+ }
VISIT(c, expr, s->v.Assert.test);
end = compiler_new_block(c);
if (end == NULL)
Seems to do the trick. Maybe this should be turned into a real patch
with using PyErr_Warn()?
n
More information about the Python-3000
mailing list