Just to point out (one of) the obvious :) (Obviously, we could add processing for more nested instances other than lists.)
arr = [1] for i in range(1000): arr = [arr] def showNested(arr): stack = [arr] s = '' while stack: curr = stack.pop() if isinstance(curr, list): s = s + '[' stack.append(']') for v in curr: stack.append(v) else: s = s + str(curr) return s
Output:
print(showNested(arr))
source share