Removing items from a list in a loop
Christian Tanzer
tanzer at swing.co.at
Wed Jun 21 11:55:42 EDT 2000
olczyk at interaccess.com (Thaddeus L. Olczyk) wrote:
> I would like to remove a bunch of items from a list *efficiently*.
> Essentially I would like to do this:
>
> for x in list:
> if Function(x):
> list.remove(x)
>
> This does not work.
list = filter (lambda x : not Function (x), list)
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list