I am starting with a text file of values and after much processing I get it to the required format: a dict of list containing n number of tuples of tuple pairs.
Here are two examples of the dict contents:
(0, 5): [((0, 5), (0, 1)), ((0, 5), (0, -3))]
(1.0, 0): [((1, 1), (2, 2)),
((1, 1), (3, 3)),
((1, 1), (-2, -2)),
((2, 2), (1, 1)),
((2, 2), (3, 3)),
((2, 2), (-2, -2)),
((3, 3), (1, 1)),
((3, 3), (2, 2)),
((3, 3), (-2, -2)),
((-2, -2), (1, 1)),
((-2, -2), (2, 2)),
((-2, -2), (3, 3))]
What I want to do is unpack the contents of the tuple pair, leaving the 'inside' tuples intact, in place.
The key, value pairs, two of which are shown above, have varying length pairs of tuples within the list. NOTE The smallest and largest are shown above.
My end result should look like this:
(0, 5): [(0, 5), (0, 1), (0, 5), (0, -3)]
(1.0, 0): [(1, 1), (2, 2),
(1, 1), (3, 3),
(1, 1), (-2, -2),
(2, 2), (1, 1),
(2, 2), (3, 3),
(2, 2), (-2, -2),
(3, 3), (1, 1),
(3, 3), (2, 2),
(3, 3), (-2, -2),
(-2, -2), (1, 1),
(-2, -2), (2, 2),
(-2, -2), (3, 3)]
NOTE 2 In place is not a requirement. I simply do not have further need of the dictionary with the contents formatted as tuples of tuple pairs.
I have found the obvious 'how to unpack a tuple' but nothing I have found is guiding me to where I need to be.
I was thinking something along the lines of:
for key, value in dic.items():
dic[key] = <unpack and update\replace existing values>
FINAL NOTE I would prefer this be done without the use of external libraries. I want to get the whole thing working locally on my machine, then 'modify' it to run it in an online environment. I can't guarantee what is and isn't already in the environment, so I am trying to use just basic built in python.