Closed cjwcommuny closed 2 years ago
It’s there already.
SortedDict
has already implemented get(key[, default])
. But can we add this method to SortedSet
?
Sets don’t typically work that way in Python.
Use inheritance to extend the data types as needed.
Add the
get(key[, default])
method for sorted container likedict
in Python.Here is the doc copied from Python standard library:
Return the value for key if key is in the dictionary, else default. If default is not given, it defaults to None, so that this method never raises a [KeyError].