Hello
I need to make checking if combination of 3 points is unique.
Decided to put first point as a key in the dictionary
the rest to points in the second dictionary.
I have a huge bunch of items consisting of 3 "double" points.
The calculations must be done on them.
Only part of combinations are unique, other combinations repeats.
initialization works:
1) how to update D1 items, which are dictionaries?
the previous code adds D2, which becomes larger and larger in every turn to D1, instead of updating.
i.e. { 0.0 : {0.1 : [0.2]}, 0.0 : {0.1 : [0.3]}, 0.0 : {0.1 : [0.4]}, .....}
instead of { 0.0 : { 0.1 : [0.2, 0.3, 0.4]}}
gives an error
2) Is there an example of linked lists in pyhton?
regards,
gintare
I need to make checking if combination of 3 points is unique.
Decided to put first point as a key in the dictionary
the rest to points in the second dictionary.
I have a huge bunch of items consisting of 3 "double" points.
The calculations must be done on them.
Only part of combinations are unique, other combinations repeats.
initialization works:
Code:
#for i, j,k..
#checking if point1, point2, point3 already exists in dictionaries...
D2.clear()
D2.setdefault(point2,[]).append(point3)
D1.setdefault(point1,[]).append(copy.deepcopy(D2))
1) how to update D1 items, which are dictionaries?
the previous code adds D2, which becomes larger and larger in every turn to D1, instead of updating.
i.e. { 0.0 : {0.1 : [0.2]}, 0.0 : {0.1 : [0.3]}, 0.0 : {0.1 : [0.4]}, .....}
instead of { 0.0 : { 0.1 : [0.2, 0.3, 0.4]}}
Code:
[COLOR="DarkRed"]D1[point1].setdefault(point[2],[])[point2]=[point3][/COLOR]
gives an error
2) Is there an example of linked lists in pyhton?
regards,
gintare