-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi Rob,
I came across this repo via stackoverflow. I was trying to use it, however noticed an issue where the existing keys are not overwritten. The below diff fixes it.
*************** class RandomDict(MutableMapping):
*** 20,30 ****
def __setitem__(self, key, val):
if key in self.keys:
i = self.keys[key]
else:
self.last_index += 1
i = self.last_index
- self.values.append((key, val))
self.keys[key] = i
def __delitem__(self, key):
--- 28,39 ----
def __setitem__(self, key, val):
if key in self.keys:
i = self.keys[key]
+ self.values[i] = (key, val)
else:
self.last_index += 1
i = self.last_index
+ self.values.append((key, val))
self.keys[key] = i
def __delitem__(self, key):
Edit: Formatting
arybin93
Metadata
Metadata
Assignees
Labels
No labels