[Python-3000] removing destructuring del

Guido van Rossum guido at python.org
Fri Feb 22 16:44:25 CET 2008


On Thu, Feb 21, 2008 at 11:27 PM, Andrew Dalke
<dalke at dalkescientific.com> wrote:
> On Feb 22, 2008, at 2:25 AM, Guido van Rossum wrote:
>  > What syntax would you allow instead? Just del variable, variable, ...?
>
>  Yes.  These are and should be legal
>
>  del a, b[1], c.d
>  del (e+f).g[9]().h
>
>  but I think this should not be legal
>
>  del a, (b, c)
>
>  That should raise
>
>    SyntaxError: can't delete tuple
>
>  and I would also like it if the following raised the same error
>
>    del (a, b)
>
>  but people use it now and I can see that perhaps, like with the from
>  statement, using '()' for long expressions is useful
>
>    del (some_very_large_variable_name[1],
>         another_large_variable_name[2].with_attribute)

Well, you could rewrite that as two del statements of course... The
only use I can think if would be

del (very_long_name.
        very_long_attribute)

>  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.

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


More information about the Python-3000 mailing list