On Wed, Sep 23, 2009 at 3:48 AM, Peter Otten <__pete...@web.de> wrote:
> Why's that obsession with speed? > Well, most of the solutions posted so far are O(n**2), which may be noticeably slow if the list is of considerable length. I wonder if the original poster ran in to that problem. >>> items = ["a", "b", "c", "d"] > >>> delenda = set([0, 3]) > >>> items = [item for index, item in enumerate(items) if index not in > delenda] > >>> items > ['b', 'c'] ... except for that one. That's O(n). Very nice. :-) -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-- http://mail.python.org/mailman/listinfo/python-list