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 things: 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. George
On 27 Sep 2007, at 21:47, George Sakkis wrote:
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 things: 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')
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 = 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 things: 1) x = : Assign x in the current namespace 2) x[i] = : Equivalent to x.__setitem__(i) 3) x.a = : Equivalent to x.__setattr__('a') and setattr(x,'a') (Sorry for the slight sarcasm, but I hope you see my point. I don't see why the deletion statement should go while the perfectly complementary and nearly-identically-"overloaded" assignment statement should stay.)
On 9/27/07, Adam Atlas <adam@atlas.st> wrote:
On 27 Sep 2007, at 21:47, George Sakkis wrote:
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 things: 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')
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 = 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 things: 1) x = : Assign x in the current namespace 2) x[i] = : Equivalent to x.__setitem__(i) 3) x.a = : Equivalent to x.__setattr__('a') and setattr(x,'a')
(Sorry for the slight sarcasm, but I hope you see my point. I don't see why the deletion statement should go while the perfectly complementary and nearly-identically-"overloaded" assignment statement should stay.)
Apples to oranges. I thought It would be obvious and that's why I didn't mention it, but getitem/setitem and friends use almost universally known punctuation; OTOH only Python AFAIK uses a keyword for a relatively infrequent operation. George
On 9/28/07, George Sakkis <george.sakkis@gmail.com> wrote:
I wonder if this was considered and rejected in the Py3K discussions; PEP 3099 doesn't mention anything about it.
Yes. del (and especially __del___) has been discussed on and off on the python-3000 list. http://mail.python.org/pipermail/python-3000/2006-September/003855.html http://mail.python.org/pipermail/python-3000/2007-May/007129.html http://mail.python.org/pipermail/python-3000/2007-May/007683.html I have used "del x" a few times to shorten the list of exported names in modules which helps epydoc. Never found any use for del x[i] or del x.a though. -- mvh Björn
On 9/28/07, BJörn Lindqvist <bjourne@gmail.com> wrote:
I have used "del x" a few times to shorten the list of exported names in modules which helps epydoc. Never found any use for del x[i] or del x.a though.
You never use dictionaries? -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (5)
-
Adam Atlas
-
BJörn Lindqvist
-
George Sakkis
-
George Sakkis
-
Guido van Rossum