I'm new to Python (coming from the Java background), so it was interesting if anyone had any advice on the structure of the data structure. I need to create a data structure with default values that would look something like this:
[
(Name="name1", {id=1, val1="val1"} ),
(Name="name2", {id=2, val1="val2"} )
]
ie a list of tuples, where each tuple consists of one string value (Name) and a dictionary of values.
The first part of the functionality that I need is the ability to add or override the above data structure with additional data, for example:
[
(Name="name2", {id=2, val1="new value"} ) ,
(Name="name2", {id=3, val1="another value"} ) ,
(Name="name3", {id=3, val1="val3"} )
]
Which ultimately leads to the final data structure, which looks like this:
[
(Name="name1", {id=1, val1="val1"} ),
(Name="name2", {id=2, val1="new value"} ) ,
(Name="name2", {id=3, val1="another value"} ) ,
(Name="name3", {id=3, val1="val3"} )
]
The second part of the functionality I need is to have access to each tuple in the list according to the id value in the ie dictionary
, name = "name2" id = "3".
- , Python?
!