[Python-Dev] list.discard? (Re: dict.discard) (original) (raw)
skip at pobox.com skip at pobox.com
Fri Sep 22 05:08:56 CEST 2006
- Previous message: [Python-Dev] list.discard? (Re: dict.discard)
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg> Actually I'd like [discard] for lists.
It's obvious for sets and dictionaries that there is only one thing to discard and that after the operation you're guaranteed the key no longer exists. Would you want the same semantics for lists or the semantics of list.remove where it only removes the first instance?
When I want to remove something from a list I typically write:
while x in somelist: somelist.remove(x)
not "if" as in your example.
Skip
- Previous message: [Python-Dev] list.discard? (Re: dict.discard)
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]