[Python-ideas] Removing the del statement
george.sakkis at gmail.com
Fri Sep 28 03:47:02 CEST 2007
I guess this has very few to zero chances of being considered, even for
Python 3, but this being python-ideas I guess it's ok to bring it up. IMO
the del statement is one of the relatively few constructs that stick out
like a sore thumb. For one thing, it is overloaded to mean three different
1) del x: Remove x from the current namespace
2) del x[i]: Equivalent to x.__delitem__(i)
3) del x.a: Equivalent to x.__delattr__('a') and delattr(x,'a')
Here I am mostly arguing for removing the last two; the first could also be
removed if/when Python gets block namespaces, but it is orthogonal to the
others. I don't see the point of complicating the lexer and the grammar with
an extra keyword and statement for something that is typically handled by a
method (my preference), or at least a generic (bulitin) function like len().
The last case is especially superfluous given that there is both a special
method and a generic builtin (delattr) that does the same thing. Neither
item nor attribute deletion are so pervasive to be granted special treatment
at the language level.
I wonder if this was considered and rejected in the Py3K discussions; PEP
3099 doesn't mention anything about it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas