Table of Contents
- ltdict
- Usage
- 0. is_ltdict(obj)
- 1. json2ltdict(obj,**kwargs)
- 2. to_json(ltd,**kwargs)
- 3. list2ltdict(array,**kwargs)
- 4. tuple2ltdict(fixed_array,**kwargs)
- 5. set2ltdict(this_set,**kwargs)
- 6. to_list(ltd,**kwargs)
- 7. to_tuple(ltd,**kwargs)
- 8. to_set(ltd,**kwargs)
- 9. extend(ltd1,ltd2,**kwargs)
- 10. prextend(ltd1,ltd2,**kwargs)
- 11. concat(ltd1,ltd2,**kwargs)
- 12. first_continuous_indexes_slice(ltd,value,**kwargs)
- 13. last_continuous_indexes_slice(ltd,value,**kwargs)
- 14. all_continuous_indexes_slices_array(ltd,value,**kwargs)
- 15. indexes_array(ltd,value,**kwargs)
- 16. first_index(ltd,value,**kwargs)
- 17. last_index(ltd,value,**kwargs)
- 18. append(ltd,value,**kwargs)
- 19. prepend(ltd,value,**kwargs)
- 20. clear(ltd,**kwargs)
- 21. insert(ltd,index,value,**kwargs)
- 22. insert_ltdict(ltd1,index,ltd2,**kwargs)
- 23. include(ltd,value,**kwargs)
- 24. count(ltd,value,**kwargs)
- 25. pop(ltd,index,**kwargs)
- 26. pop_range(ltd,start,end,**kwargs)
- 27. pop_seqs(ltd,seqs_set,**kwargs)
- 28. remove_first(ltd,value,**kwargs)
- 29. remove_last(ltd,value,**kwargs)
- 30. remove_all(ltd,value,**kwargs)
- 31. reverse(ltd,**kwargs)
- 32. sort(ltd,**kwargs)
- 33. comprise(ltd1,ltd2,**kwargs)
- 34. naturalize_intkeydict(ikd)
- list style dict,
$ pip3 install ltdict
- MIT
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:1,1:2,2:3} is_ltdict(ltd) == True ltd = {0:1,2:2,3:3} is_ltdict(ltd) == False ltd = {0:1,'1':2,2:3} is_ltdict(ltd) == False
from ltdict.ltdict import * from xdict.jprint import pobj,pdir json_dict = {'0':'a','1':'b','2':'c'} json2ltdict(json_dict) == {0:'a',1:'b',2:'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c'} to_json(ltd) == {'1': 'b', '2': 'c', '0': 'a'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir array = ['a','b','c'] list2ltdict(array) == {0: 'a', 1: 'b', 2: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir t = ('a','b','c') tuple2ltdict(t) == {0: 'a', 1: 'b', 2: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir s = {'a','b','c'} set2ltdict(s)
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} to_list(ltd) == ['a', 'b', 'c']
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} to_tuple(ltd) == ('a', 'b', 'c')
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} to_set(ltd) == {'b', 'c', 'a'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd1 = {0: 'a', 1: 'b', 2: 'c'} ltd2 = {0: 'd', 1: 'e', 2: 'f'} extend(ltd1,ltd2) == {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd1 = {0: 'a', 1: 'b', 2: 'c'} ltd2 = {0: 'd', 1: 'e', 2: 'f'} prextend(ltd1,ltd2) == {0: 'd', 1: 'e', 2: 'f', 3: 'a', 4: 'b', 5: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd1 = {0: 'a', 1: 'b', 2: 'c'} ltd2 = {0: 'd', 1: 'e', 2: 'f'} concat(ltd1,ltd2) == {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} first_continuous_indexes_slice(ltd,'c') == [2, 3]
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} last_continuous_indexes_slice(ltd,'c') == [8, 9]
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} all_continuous_indexes_slices_array(ltd,'c') == [[2, 3], [5], [8, 9]]
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} indexes_array(ltd,'c') == [2, 3, 5, 8, 9]
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} first_index(ltd,'c') == 2
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} last_index(ltd,'c') == 9
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} append(ltd,'d') == {0: 'a', 1: 'b', 2: 'c', 3: 'd'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} prepend(ltd,'d') == {0: 'd', 1: 'a', 2: 'b', 3: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} clear(ltd) == {}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} insert(ltd,1,'d') == {0: 'a', 1: 'd', 2: 'b', 3: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd1 = {0: 'a', 1: 'b', 2: 'c'} ltd2 = {0: 'd', 1: 'e', 2: 'f'} insert_ltdict(ltd1,1,ltd2) == {0: 'a', 1: 'd', 2: 'e', 3: 'f', 4: 'b', 5: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} include(ltd,'c') == True
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} count(ltd,'c') == 5
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0: 'a', 1: 'b', 2: 'c'} pop(ltd,1) == 'b' ltd == {0: 'a', 1: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} pop_range(ltd,1,7) == {0: 'b', 1: 'c', 2: 'c', 3: 'd', 4: 'c', 5: 'e', 6: 'f'} ltd == {0: 'a', 1: 'c', 2: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} seqs_set = {2,5,8} pop_seqs(ltd,seqs_set) == {0: 'c', 1: 'c', 2: 'c'} ltd == {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'e', 5: 'f', 6: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} remove_first(ltd,'c') == {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'c', 5: 'e', 6: 'f', 7: 'c', 8: 'c'} ltd == {0: 'a', 1: 'b', 2: 'c', 3: 'd', 4: 'c', 5: 'e', 6: 'f', 7: 'c', 8: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} remove_last(ltd,'c') == {0: 'a', 1: 'b', 2: 'c', 3: 'c', 4: 'd', 5: 'c', 6: 'e', 7: 'f', 8: 'c'} ltd == {0: 'a', 1: 'b', 2: 'c', 3: 'c', 4: 'd', 5: 'c', 6: 'e', 7: 'f', 8: 'c'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} remove_all(ltd,'c') == {0: 'a', 1: 'b', 2: 'd', 3: 'e', 4: 'f'} ltd == {0: 'a', 1: 'b', 2: 'd', 3: 'e', 4: 'f'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} reverse(ltd) == {0: 'c', 1: 'c', 2: 'f', 3: 'e', 4: 'c', 5: 'd', 6: 'c', 7: 'c', 8: 'b', 9: 'a'} ltd == {0: 'c', 1: 'c', 2: 'f', 3: 'e', 4: 'c', 5: 'd', 6: 'c', 7: 'c', 8: 'b', 9: 'a'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd = {0:'a',1:'b',2:'c',3:'c',4:'d',5:'c',6:'e',7:'f',8:'c',9:'c'} sort(ltd) == {0: 'a', 1: 'b', 2: 'c', 3: 'c', 4: 'c', 5: 'c', 6: 'c', 7: 'd', 8: 'e', 9: 'f'} ltd == {0: 'a', 1: 'b', 2: 'c', 3: 'c', 4: 'c', 5: 'c', 6: 'c', 7: 'd', 8: 'e', 9: 'f'}
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ltd1 = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f'} ltd2 = {0:'a',1:'b',2:'c'} comprise(ltd1,ltd2) == True ltd3 = {0:'c',1:'d',2:'e'} comprise(ltd1,ltd3) == False comprise(ltd1,ltd3,strict=False) == True
from ltdict.ltdict import * from xdict.jprint import pobj,pdir ikd = {3:'a',1:'b',2:'c',11:'d',0:'e',50:'f'} naturalize_intkeydict(ikd) == {0: 'e', 1: 'b', 2: 'c', 3: 'a', 4: 'd', 5: 'f'}