>>>>> SuperHik <[EMAIL PROTECTED]> (S) escribió:

>S> [EMAIL PROTECTED] wrote:
>>> python wrote:
>>>> after del list , when I use it again, prompt 'not defined'.how could i
>>>> delete its element,but not itself?
>>> 
>>> This is a way:
>>>>>> a = range(10)
>>>>>> del a[:]
>S> or simply
>S> a = []
>>>>>> a
>>> []

Then you *have* deleted the list and created a new one, which is different
from keeping the list and deleting the elements:

>>> a = range(10)
>>> b = a
>>> del a[:]
>>> a
[]
>>> b
[]
>>> a.append(100)
>>> a
[100]
>>> b
[100]
>>> a=[]
>>> b
[100]
>>> 
-- 
Piet van Oostrum <[EMAIL PROTECTED]>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to