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

Padraig Brady Padraig at Linux.ie
Wed Oct 9 04:43:33 EDT 2002


Greg Brunet wrote:
> I'm just trying to learn Python, and one thing that struck me as odd
> was that to delete a specific list element, I need to use a statement
> instead of a method like I use for almost everything else I do on the
> list.  This seems a bit inconsistent.  Why wouldn't it be a method?
> 

Being a python newbie myself this strck me as a little inconsistent.

why can't you do:

l=[1,2,3]
s="123"
i=123

l[1].del()
l.del()
s.del()
i.del()

Same goes for len() et. al.

Pádraig.




More information about the Python-list mailing list