Formatted printing of deep tuples

Ignacio Vazquez-Abrams ignacio at openservices.net
Fri Oct 5 01:30:23 EDT 2001


Okay, here's a good one. Say I have a tuple as follows:

---
(((1, 2),), ((), ('a', (('b', 'c'),))))
---

Does anyone have or know of any code that will format it similar to:

---
(
  (
    (
      1, 2
    ),
  ),
  (
    (
    ),
    (
      'a',
      (
        (
          'b', 'c'
        ),
      )
    )
  )
)
---

It doesn't have to be exactly as shown, but the pprint module just doesn't cut
it for more than 3 levels or so.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>





More information about the Python-list mailing list