As the other answers suggest pprint module does the trick.
Nonetheless, in case of debugging where you might need to put the entire list into some log file, one might have to use pformat method along with module logging along with pprint.
import logging
from pprint import pformat
logger = logging.getLogger('newlogger')
handler = logging.FileHandler('newlogger.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.WARNING)
data = [ (i, { '1':'one',
'2':'two',
'3':'three',
'4':'four',
'5':'five',
'6':'six',
'7':'seven',
'8':'eight',
})
for i in xrange(3)
]
logger.error(pformat(data))
And if you need to directly log it to a File, one would have to specify an output stream, using the stream keyword. Ref
from pprint import pprint
with open('output.txt', 'wt') as out:
pprint(myTree, stream=out)