[Python-Dev] list.discard? (Re: dict.discard) (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 22 02:21:01 CEST 2006
- Previous message: [Python-Dev] dict.discard
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Gustavo Niemeyer wrote:
>>> print set.discard.doc Remove an element from a set if it is a member.
Actually I'd like this for lists. Often I find myself writing
if x not in somelist: somelist.remove(x)
A single method for doing this would be handy, and more efficient.
-- Greg
- Previous message: [Python-Dev] dict.discard
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]