clear derived list

Steven Taschuk staschuk at telusplanet.net
Wed Mar 12 01:34:08 CET 2003


Quoth John Hunter:
  [...]
> class mylist(list):
>     def set(self, seq):
>         # flush the old list
>         [self.pop() for i in range(len(self))]
>         self.extend(seq)

How about using slice assignment?

	def set(self, seq):
		self[:] = seq

-- 
Steven Taschuk                                                 o- @
staschuk at telusplanet.net                                      7O   )
                                                               "  (





More information about the Python-list mailing list