[Python-3000] removing destructuring del
Alexander Belopolsky
alexander.belopolsky at gmail.com
Fri Feb 22 18:07:12 CET 2008
Guido van Rossum <guido <at> python.org> writes:
>
> On Thu, Feb 21, 2008 at 11:27 PM, Andrew Dalke
> <dalke <at> dalkescientific.com> wrote:
> .. I think this should not be legal
> >
> > del a, (b, c)
> >
> > That should raise
> >
> > SyntaxError: can't delete tuple
..
> 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.
>
I was always wondering why both lists and tuples are allowed as
assignment targets. As far as I can tell, the only difference is in
the corner cases such as
>>> del []
>>> del ()
File "<stdin>", line 1
SyntaxError: can't assign to ()
>>> [] = ()
>>> () = ()
File "<stdin>", line 1
SyntaxError: can't assign to ()
Maybe Py3k should eliminate the list form, but allow empty tuples
as useful in auto-generated code (deleting variable number of
names.)
More information about the Python-3000
mailing list