The del statement

Marco Aschwanden PPNTWIMBXFFC at spammotel.com
Tue Dec 5 03:50:17 EST 2006


> so what about
>
>      del x

Ups. I never used it for an object. So far I only used it for deletion of  
elements of a container. In that case del has two purposes:

1. Deletes an item from a container (and of course destructs it) -->  
list.remove(elem)
2. Calls the destructor of an object --> list.destruct()

One statement and two distinct purposes. Why not having two "standard"  
function (for containers we have a remove-function) and all objects have a  
destruct-function. Still no need for a del keyword.

A del keyword that calls the destructor... well that is okay (it could be  
handled without). I am used to see the del keyword in opposition to the  
new keyword (which does not exist/is implicit in Python).

The del keyword for removing an element in a container is a bit awkward to  
me.

I am not as knowledgeable about languages as you are and I am hoping  
people like you can enlighten me about the language decision taken.

> for the curious, guido's rationale for len() can be found here:
>
>    http://preview.tinyurl.com/y6vavp

Thanks for the hint.
Marco




More information about the Python-list mailing list