[Tutor] question about removing items from a list

Lance E Sloan lsloan@umich.edu
Wed, 15 Aug 2001 09:51:15 -0400


"Allan Crooks" wrote:
> An even better way would be like this:
> 
> del lista[:]
> 
> That would delete all items within the list. Doing 'del lista' would 
> simply delete the list itself.

What about:

  lista = []

That would give the intended effect, but I wonder what happens to the
original list that lista pointed to.  Does it hang around in memory,
or does Python's garbage collection get rid of it as soon as nothing
points to it any longer?

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Perl & Python CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"