File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,12 @@ Basics
4141 # the key is split on '.'s and works on dictionaries
4242 del store[' a_dictionary.dict-list' ]
4343 store[' a_dictionary.new_value' ] = " old value"
44+ # you can also use the syntactic sugar for tuple keys (explicit lists work too)
4445 assert store[' a_dictionary' , ' new_value' ] == " old value"
45- assert store[' a_list' , 1 ] == 2
46+ # you can traverse lists too
47+ assert store[' a_list' , - 1 ] == 3
48+ # you can use slices in lists
49+ assert len (store[' a_list' , 1 :]) == 2
4650
4751 # deep copies are made when assigning values
4852 my_list = [' fun' ]
Original file line number Diff line number Diff line change @@ -170,12 +170,13 @@ def test_nested_dict_helper(self):
170170 def test_nested_getitem (self ):
171171 self .store ["list" ] = [
172172 {
173- "key" : [None , "value" ]
173+ "key" : [None , "value" , "last" ]
174174 }
175175 ]
176176 assert self .store ["list" , 0 , "key" , 1 ] == "value"
177- assert self .store [["list" , 0 , "key" , 1 ]] == "value "
177+ assert self .store [["list" , 0 , "key" , - 1 ]] == "last "
178178 self .assertRaises (TypeError , self ._getitem ("list.0.key.1" ))
179+ assert len (self .store ["list" , 0 , "key" , 1 :]) == 2
179180
180181 def test_del (self ):
181182 self .store .key = None
You can’t perform that action at this time.
0 commit comments