In PHP, I can do this:
echo '<pre>'
print_r($array);
echo '</pre>'
In Python, I currently just do this:
print the_list
However, this will cause a big jumbo of data. Is there any way to print it nicely into a readable tree? (with indents)?
In PHP, I can do this:
echo '<pre>'
print_r($array);
echo '</pre>'
In Python, I currently just do this:
print the_list
However, this will cause a big jumbo of data. Is there any way to print it nicely into a readable tree? (with indents)?
You mean something like...:
>>> print L
['this', 'is', 'a', ['and', 'a', 'sublist', 'too'], 'list', 'including', 'many', 'words', 'in', 'it']
>>> import pprint
>>> pprint.pprint(L)
['this',
'is',
'a',
['and', 'a', 'sublist', 'too'],
'list',
'including',
'many',
'words',
'in',
'it']
>>>
...? From your cursory description, standard library module pprint is the first thing that comes to mind; however, if you can describe example inputs and outputs (so that one doesn't have to learn PHP in order to help you;-), it may be possible for us to offer more specific help!