[Python-bugs-list] [ python-Feature Requests-805255 ] remove/discard method for dict objects.

SourceForge.net noreply at sourceforge.net
Fri Sep 12 15:08:02 EDT 2003


Feature Requests item #805255, was opened at 2003-09-12 15:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=805255&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jeremy Fincher (jemfinch)
Assigned to: Nobody/Anonymous (nobody)
Summary: remove/discard method for dict objects.

Initial Comment:
dict objects already provide a method for getting from

the dictionary (possibly returning a default value) so

as to avoid raising KeyError.  But there's no way to

remove an item that may or may not be in a dictionary

from a dictionary without risking raising KeyError.



I think there should be a method to remove a key if it

is in the dictionary, but to do nothing if it isn't. 

I'd suggest calling it .remove, but the sets.Set type

offers this functionality as .discard, so perhaps

that's a better name.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=805255&group_id=5470



More information about the Python-bugs-list mailing list