Why is del(ete) a statement instead of a method?

Greg Brunet gbrunet at sempersoft.com
Wed Oct 9 09:08:12 EDT 2002


Chad (and others):

Thanks for the response, though (and you are probably expecting this
response):

> Because del works on a lot more than just lists; you can 'del' any object 
> (although it doesn't mean the object actually is deleted from use; typically 
> it just means the local reference to it is removed)

So why don't all objects support a .del method?  That would seem to be
the most consistent behavior. Then you could still use .remove(value)
to remove by value, and .del(index) to remove by index, and .del() to
delete the whole list.  I agree for the need for a .del action
(statement / function / method).  I just don't understand why it's not
a method.  For me, in addition to being more consistent, another
(admittedly minor) advantage of having it as a method is that the
IDE's do a better job in Auto-Completing and prompting me for
arguments with methods than with it as a statement.

-- 
Greg



More information about the Python-list mailing list