del
Grant Edwards
grante at visi.com
Fri Feb 14 18:42:45 EST 2003
In article <b2jsir$csa$1 at camelot.ccs.neu.edu>, Daniel Silva wrote:
> What is the purpose of the del statement?
To delete things. :)
> Why would you want to undefine a variable? More precisely, how
> many programs would be broken if a python compiler did not
> implement it?
Many of mine would.
I often use it to delete items from a list or dictionary:
>>> x = [1,2,3,4]
>>> del x[1]
>>> x
[1, 3, 4]
>>> d
{3: 'three', 2: 'two', 1: 'one'}
>>> del d[2]
>>> d
{3: 'three', 1: 'one'}
--
Grant Edwards grante Yow! Well, I'm on the
at right planet---everyone
visi.com looks like me!!!
More information about the Python-list
mailing list