Supported updates of an array by negative index
This commit is contained in:
parent
bb0b1e88ef
commit
6a4c342e45
@ -108,6 +108,9 @@ class BaseList(list):
|
||||
super(BaseList, self).__init__(list_items)
|
||||
|
||||
def __getitem__(self, key):
|
||||
# change index to positive value because MongoDB does not support negative one
|
||||
if isinstance(key, int) and key < 0:
|
||||
key = len(self) + key
|
||||
value = super(BaseList, self).__getitem__(key)
|
||||
|
||||
if isinstance(key, slice):
|
||||
|
Loading…
x
Reference in New Issue
Block a user