dictionary with dictionaries, linked list

Joined
Aug 27, 2009
Messages
1
Reaction score
0
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:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top