why del is not a function or method?

Robin Becker robin at reportlab.com
Wed Oct 18 04:28:34 EDT 2017


On 16/10/2017 16:37, Xue Feng via Python-list wrote:
> Hi,
>     I wonder why 'del' is not a function or method. Most operations can be used 
> as follows
>          len(team)
> or
>          team.append("tom")
> But, I think
>          del team[2]
> is somewhat uncommon. Why does not it take a syntax we are famillar with?
It can look like a function

>>>> x = 3
>>>> del(x)
>>>> x
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'x' is not defined
>>>>


-- 
Robin Becker




More information about the Python-list mailing list