[Tutor] Correcting myself

Charlie Clark charlie@begeistert.org
Fri, 05 Apr 2002 09:02:30 +0200


On 2002-04-05 at 02:10:02 [+0200], tutor-request@python.org wrote:
> for line in inp.readlines():
> if x is in inp.readlines del x
> del removes an item from a sequence.
This is wrong, sorry! del removes something from the current namespace - it really deletes objects! List have the remove method. I don't use either very often which is probably why I find it easy to confuse them.
l = ['a', 'b', 'c']
l.remove('a')
l
>>> ['b', 'c']
del l
l
>>>NameError: name 'l' is not defined 

Charlie