[Python-ideas] Allow multiple arguments to `list.remove` and flag for silent fail

Sébastien Volle sebastien.volle at gmail.com
Mon Aug 26 23:07:00 CEST 2013


List comprehension works too:

my_list = [ thing for thing in my_list if thing not in things ]

But both our solutions don't change my_list in place but require creating a
new list, and would not be very practical with big lists.

Anyway, I'd rather stick with the simple for loop than making list methods
too clever.

-- seb
Le 26 août 2013 19:56, <random832 at fastmail.us> a écrit :

> On Mon, Aug 26, 2013, at 13:11, Ram Rachum wrote:
> > my_list.remove(*things, silent_fail=True)
> >
> >
> > Aside from being much more concise, it could be more efficient too,
> > couldn't it?
>
> my_list = list(filter(lambda x: x in things, my_list))
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130826/e7eb6618/attachment.html>


More information about the Python-ideas mailing list