I wrote a function that accepts, works, and returns simple, non-nested tuples.
eg:.
myfun((1,2,3,4)):
... -> logic
return (1,2,3,4) -> the numbers can change, but the shape will be the same
Since the logic only works with one-dimensional tuples, it is conceptually the same for each level of nesting. I was wondering if there is a way to convert a nested type tuple ((1,2,(3,)),(4,))into a regular one (1,2,3,4), and then convert it back to ((1,2,(3,)),(4,)).
Basically, I want to unpack a common input tuple, work with it, and then pack the results in the same kind of data.
Is there a pythonic way to accomplish such a task?
Unpacking can probably be resolved with recursion, however, I'm not sure about the "re-packing" part.