Last active
November 18, 2022 13:46
-
-
Save jj-github-jj/fbf58f772f885d9e2e979113f6da86a5 to your computer and use it in GitHub Desktop.
array of data structures (dicts) python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
from metadict import MetaDict | |
''' define data structure using dict Metadict''' | |
tl_dict=MetaDict ({f'L{n}': 0 for n in range (4)}) | |
''' use dot access . Can create array of these | |
data structure built using dict (MetaDIct allows dot access) | |
''' | |
def set_dict(d,values): | |
d=copy.deepcopy(d) | |
for k,v in zip (d,values): # iterate over keys | |
d[k]=v | |
return (d) | |
tl_values_default=[100,101,102,122,123] | |
tl2_values=[200,201,302,422,123] | |
tl_default= set_dict(tl_dict,tl_values_default) | |
tl_2=set_dict(tl_dict,tl2_values) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment